c++ - 3d C 阵列组装
问题描述
我在视频缓冲区中一起渲染 10x12 像素图
buffer[20][512] = malloc(10*12)
我在 20 个组中有多达 512 个潜在的 10x12 位图。我只使用一个组号:0 buffer[group][number of 10x12 tiles]
因此,buffer[0][mapindex]
每次调用该函数时,我只需要索引不同的地图。我将缓冲区传递给 nasm 函数tile_render(buffer,0,mapindex);
这是我迷路的地方:
lea esi,[ebp + 12]; Passing the buffer from the stack
mov eax,[ebp + 36] ;Location of mapindex on the stack
I am looping through 10 x 12 trying to render the pixels
mov dl,[4*esi + eax +8]
move byte [edi + ebx],dl ;moving one byte at a time.
//code omitted
add ebx,320
但是,我没有找到 10x12 像素的正确地址,这意味着我只是在屏幕上出现乱码。
当然还有其他方法可以处理这个问题,我可以做得很好,但我想知道如何在汇编中更好地使用 3 维数组。在这方面,我的经验是新手,所以我希望有人以前处理过这种情况。
解决方案
找到了这个案例的解决方案:
mov esi,[ebp + 12] ; buffer[20][512] = malloc(10*12)
mov edx,[esi] ;Move to first bitmap
lea esi,[edx] ;first bitmap address
mov eax,[ebx + 36] ;index to each map
mov ecx,120 ;120 = 12x10 size bit map
mul ecx ;120 x map index.
mov dl. [esi + eax] ;index through to the output buffer
mov [edi + ebx],dl ; next
.
.
.
add ebx,320
推荐阅读
- xaml - 如何在 Xamarin Forms 中的另一个布局之上覆盖卡片视图或框架布局?
- angular - 为什么 BehaviorSubject 不是异步的?
- node.js - 如何使用nodejs socket.io向特定房间的用户发送打字警报和消息
- methods - julia 为包含 NTuple 的结构实现转换
- node.js - Lambda:属性层的值必须是字符串列表类型
- r - 如何从 R 导出和保存矢量
- java - 为什么即使使用 Spring Data JPA 与 CascadeType.PERSIST 也必须同步双向关系
- powershell - Powershell ps1 脚本运行 bat 文件但 CMD 屏幕在执行后关闭
- swift - SwiftUI - 基于 ObservedObject 的条件在后续视图中不起作用
- javascript - 尝试获取通道时未定义客户端