Legolas
28-09-2006, 07:12 PM
I need a little help with fpc4gba: I have a bug I'm not able to resolve by myself... look at this code:
program main;
{ $DEFINE USE_SWAP}
uses
gba_types, gba_video, gba_regs, gba_bg, gba_core;
var
sMap: array [0..4] of u16;
blockLayer: pu16;
value: u16;
begin
blockLayer := MEMBGMAP(1); // This is like blocklayer: pu16 absolute $6004000;
SetMode(MODE_3 or BG2_ENABLE);
sMap[2] := 15;
{$ifndef USE_SWAP}
blockLayer[2] := sMap[2];
{$else}
value := sMap[2];
blockLayer[2] := value;
{$endif}
if blockLayer[2] = 15 then
VideoBuffer[16000] := $001F; // Never reached if USE_SWAP is undefined
end.
It should put a red pixel on the gba screen only if the value of sMap[2] is passed to blockLayer[2]. As you can see, it fails if I try to assign it directly from array to array, but works if I assign the value by passing it in another variable. :doh:
By checking the map file, I can see that in both cases sMap and blockLayer are created in the same memory region, that is readable and writeable ($3000000).
Any ideas? :think: :eh: :scratch:
program main;
{ $DEFINE USE_SWAP}
uses
gba_types, gba_video, gba_regs, gba_bg, gba_core;
var
sMap: array [0..4] of u16;
blockLayer: pu16;
value: u16;
begin
blockLayer := MEMBGMAP(1); // This is like blocklayer: pu16 absolute $6004000;
SetMode(MODE_3 or BG2_ENABLE);
sMap[2] := 15;
{$ifndef USE_SWAP}
blockLayer[2] := sMap[2];
{$else}
value := sMap[2];
blockLayer[2] := value;
{$endif}
if blockLayer[2] = 15 then
VideoBuffer[16000] := $001F; // Never reached if USE_SWAP is undefined
end.
It should put a red pixel on the gba screen only if the value of sMap[2] is passed to blockLayer[2]. As you can see, it fails if I try to assign it directly from array to array, but works if I assign the value by passing it in another variable. :doh:
By checking the map file, I can see that in both cases sMap and blockLayer are created in the same memory region, that is readable and writeable ($3000000).
Any ideas? :think: :eh: :scratch: