mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-15 22:28:10 +00:00
DREAMWEB: Encapsulated some endian conversions in accessors
This commit is contained in:
parent
5de064f1e4
commit
69f7a6bcdf
@ -39,7 +39,7 @@ void DreamGenContext::printsprites() {
|
||||
Sprite *sprites = spritetable();
|
||||
for (size_t j = 0; j < 16; ++j) {
|
||||
const Sprite &sprite = sprites[j];
|
||||
if (READ_LE_UINT16(&sprite.updateCallback) == 0x0ffff)
|
||||
if (sprite.updateCallback() == 0x0ffff)
|
||||
continue;
|
||||
if (priority != sprite.priority)
|
||||
continue;
|
||||
@ -83,7 +83,7 @@ Sprite *DreamGenContext::makesprite(uint8 x, uint8 y, uint16 updateCallback, uin
|
||||
++sprite;
|
||||
}
|
||||
|
||||
WRITE_LE_UINT16(&sprite->updateCallback, updateCallback);
|
||||
sprite->setUpdateCallback(updateCallback);
|
||||
sprite->x = x;
|
||||
sprite->y = y;
|
||||
WRITE_LE_UINT16(&sprite->w6, somethingInDx);
|
||||
@ -111,7 +111,7 @@ void DreamGenContext::spriteupdate() {
|
||||
|
||||
Sprite *sprite = sprites;
|
||||
for (size_t i=0; i < 16; ++i) {
|
||||
uint16 updateCallback = READ_LE_UINT16(&sprite->updateCallback);
|
||||
uint16 updateCallback = sprite->updateCallback();
|
||||
if (updateCallback != 0xffff) {
|
||||
sprite->w24 = sprite->w2;
|
||||
if (updateCallback == addr_mainman) // NB : Let's consider the callback as an enum while more code is not ported to C++
|
||||
@ -279,7 +279,7 @@ void DreamGenContext::backobject(Sprite *sprite) {
|
||||
push(ds);
|
||||
|
||||
ds = data.word(kSetdat);
|
||||
di = READ_LE_UINT16(&sprite->obj_data);
|
||||
di = sprite->objData();
|
||||
ObjData *objData = (ObjData *)ds.ptr(di, 0);
|
||||
|
||||
if (sprite->delay != 0) {
|
||||
|
@ -20,8 +20,12 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "common/endian.h"
|
||||
|
||||
struct Sprite {
|
||||
uint16 updateCallback;
|
||||
uint16 _updateCallback;
|
||||
uint16 updateCallback() const { return READ_LE_UINT16(&_updateCallback); }
|
||||
void setUpdateCallback(uint16 v) { WRITE_LE_UINT16(&_updateCallback, v); }
|
||||
uint16 w2;
|
||||
uint16 w4;
|
||||
uint16 w6;
|
||||
@ -35,7 +39,9 @@ struct Sprite {
|
||||
uint8 b17;
|
||||
uint8 delay;
|
||||
uint8 frame;
|
||||
uint16 obj_data;
|
||||
uint16 _objData;
|
||||
uint16 objData() const { return READ_LE_UINT16(&_objData); }
|
||||
void setObjData(uint16 v) { WRITE_LE_UINT16(&_objData, v); }
|
||||
uint8 b22;
|
||||
uint8 priority;
|
||||
uint16 w24;
|
||||
|
@ -892,7 +892,7 @@ void DreamGenContext::eraseoldobs() {
|
||||
Sprite *sprites = spritetable();
|
||||
for (size_t i=0; i < 16; ++i) {
|
||||
Sprite &sprite = sprites[i];
|
||||
if (READ_LE_UINT16(&sprite.obj_data) != 0xffff) {
|
||||
if (sprite.objData() != 0xffff) {
|
||||
memset(&sprite, 0xff, sizeof(Sprite));
|
||||
}
|
||||
}
|
||||
@ -985,7 +985,7 @@ void DreamGenContext::makebackob() {
|
||||
Sprite *sprites = (Sprite *)es.ptr(bx, sizeof(Sprite) * 16);
|
||||
bx += sizeof(Sprite) * (sprite - sprites);
|
||||
//
|
||||
WRITE_LE_UINT16(&sprite->obj_data, si);
|
||||
sprite->setObjData(si);
|
||||
if (priority == 255)
|
||||
priority = 0;
|
||||
sprite->priority = priority;
|
||||
|
Loading…
Reference in New Issue
Block a user