@@ -9,113 +9,145 @@ unit machine; |
| 9 |
|
9 |
|
| 10 |
{$MODE Delphi} |
10 |
{$MODE Delphi} |
| 11 |
|
11 |
|
| 12 |
interface uses windows; |
12 |
interface |
|
|
13 |
|
|
|
14 |
uses Windows; |
| 13 |
|
15 |
|
| 14 |
const |
16 |
const |
| 15 |
MaxCompanies=74; |
17 |
MaxCompanies = 74; |
| 16 |
|
18 |
|
| 17 |
Companies:Array[0..maxCompanies] of record Code:Word;Name:String end= |
19 |
Companies: array[0..maxCompanies] of record |
| 18 |
( |
20 |
Code: word; |
| 19 |
( code:$3301;Name:'Nintendo' ),( code:$7901;Name:'Accolade' ),( code:$A400;Name:'Konami' ), |
21 |
Name: string |
| 20 |
( code:$6701;Name:'Ocean' ),( code:$5601;Name:'LJN' ),( code:$9900;Name:'ARC?' ), |
22 |
end |
| 21 |
( code:$0101;Name:'Nintendo' ),( code:$0801;Name:'Capcom' ),( code:$0100;Name:'Nintendo' ), |
23 |
= |
| 22 |
( code:$BB01;Name:'SunSoft' ),( code:$A401;Name:'Konami' ),( code:$AF01;Name:'Namcot?' ), |
24 |
( |
| 23 |
( code:$4901;Name:'Irem' ),( code:$9C01;Name:'Imagineer' ),( code:$A600;Name:'Kawada?' ), |
25 |
(code: $3301; Name: 'Nintendo'), (code: $7901; Name: 'Accolade'), (code: $A400; |
| 24 |
( code:$B101;Name:'Nexoft' ),( code:$5101;Name:'Acclaim' ),( code:$6001;Name:'Titus' ), |
26 |
Name: 'Konami'), |
| 25 |
( code:$B601;Name:'HAL' ),( code:$3300;Name:'Nintendo' ),( code:$0B00;Name:'Coconuts?' ), |
27 |
(code: $6701; Name: 'Ocean'), (code: $5601; Name: 'LJN'), (code: $9900; |
| 26 |
( code:$5401;Name:'Gametek' ),( code:$7F01;Name:'Kemco?' ),( code:$C001;Name:'Taito' ), |
28 |
Name: 'ARC?'), |
| 27 |
( code:$EB01;Name:'Atlus' ),( code:$E800;Name:'Asmik?' ),( code:$DA00;Name:'Tomy?' ), |
29 |
(code: $0101; Name: 'Nintendo'), (code: $0801; Name: 'Capcom'), (code: $0100; |
| 28 |
( code:$B100;Name:'ASCII?' ),( code:$EB00;Name:'Atlus' ),( code:$C000;Name:'Taito' ), |
30 |
Name: 'Nintendo'), |
| 29 |
( code:$9C00;Name:'Imagineer' ),( code:$C201;Name:'Kemco?' ),( code:$D101;Name:'Sofel?' ), |
31 |
(code: $BB01; Name: 'SunSoft'), (code: $A401; Name: 'Konami'), (code: $AF01; |
| 30 |
( code:$6101;Name:'Virgin' ),( code:$BB00;Name:'SunSoft' ),( code:$CE01;Name:'FCI?' ), |
32 |
Name: 'Namcot?'), |
| 31 |
( code:$B400;Name:'Enix?' ),( code:$BD01;Name:'Imagesoft' ),( code:$0A01;Name:'Jaleco?' ), |
33 |
(code: $4901; Name: 'Irem'), (code: $9C01; Name: 'Imagineer'), (code: $A600; |
| 32 |
( code:$DF00;Name:'Altron?' ),( code:$A700;Name:'Takara?' ),( code:$EE00;Name:'IGS?' ), |
34 |
Name: 'Kawada?'), |
| 33 |
( code:$8300;Name:'Lozc?' ),( code:$5001;Name:'Absolute?' ),( code:$DD00;Name:'NCS?' ), |
35 |
(code: $B101; Name: 'Nexoft'), (code: $5101; Name: 'Acclaim'), (code: $6001; |
| 34 |
( code:$E500;Name:'Epoch?' ),( code:$CB00;Name:'VAP?' ),( code:$8C00;Name:'Vic Tokai' ), |
36 |
Name: 'Titus'), |
| 35 |
( code:$C200;Name:'Kemco?' ),( code:$BF00;Name:'Sammy?' ), |
37 |
(code: $B601; Name: 'HAL'), (code: $3300; Name: 'Nintendo'), (code: $0B00; |
| 36 |
( code:$1800;Name:'Hudson Soft' ),( code:$CA01;Name:'Palcom/Ultra' ), |
38 |
Name: 'Coconuts?'), |
| 37 |
( code:$CA00;Name:'Palcom/Ultra' ),( code:$C500;Name:'Data East?' ), |
39 |
(code: $5401; Name: 'Gametek'), (code: $7F01; Name: 'Kemco?'), (code: $C001; |
| 38 |
( code:$A900;Name:'Technos Japan?' ),( code:$D900;Name:'Banpresto?' ), |
40 |
Name: 'Taito'), |
| 39 |
( code:$7201;Name:'Broderbund?' ),( code:$7A01;Name:'Triffix Entertainment?' ), |
41 |
(code: $EB01; Name: 'Atlus'), (code: $E800; Name: 'Asmik?'), (code: $DA00; |
| 40 |
( code:$E100;Name:'Towachiki?' ),( code:$9300;Name:'Tsuburava?' ), |
42 |
Name: 'Tomy?'), |
| 41 |
( code:$C600;Name:'Tonkin House?' ),( code:$CE00;Name:'Pony Canyon' ), |
43 |
(code: $B100; Name: 'ASCII?'), (code: $EB00; Name: 'Atlus'), (code: $C000; |
| 42 |
( code:$7001;Name:'Infogrames?' ),( code:$8B01;Name:'Bullet-Proof Software?' ), |
44 |
Name: 'Taito'), |
| 43 |
( code:$5501;Name:'Park Place?' ),( code:$EA00;Name:'King Records?' ), |
45 |
(code: $9C00; Name: 'Imagineer'), (code: $C201; Name: 'Kemco?'), (code: $D101; |
| 44 |
( code:$5D01;Name:'Tradewest?' ),( code:$6F01;Name:'ElectroBrain?' ), |
46 |
Name: 'Sofel?'), |
| 45 |
( code:$AA01;Name:'Broderbund?' ),( code:$C301;Name:'SquareSoft' ), |
47 |
(code: $6101; Name: 'Virgin'), (code: $BB00; Name: 'SunSoft'), (code: $CE01; |
| 46 |
( code:$5201;Name:'Activision?' ),( code:$5A01;Name:'Bitmap Brothers/Mindscape' ), |
48 |
Name: 'FCI?'), |
| 47 |
( code:$5301;Name:'American Sammy' ),( code:$4701;Name:'Spectrum Holobyte' ), |
49 |
(code: $B400; Name: 'Enix?'), (code: $BD01; Name: 'Imagesoft'), (code: $0A01; |
| 48 |
( code:$1801;Name:'Hudson Soft')); |
50 |
Name: 'Jaleco?'), |
|
|
51 |
(code: $DF00; Name: 'Altron?'), (code: $A700; Name: 'Takara?'), (code: $EE00; |
|
|
52 |
Name: 'IGS?'), |
|
|
53 |
(code: $8300; Name: 'Lozc?'), (code: $5001; Name: 'Absolute?'), (code: $DD00; |
|
|
54 |
Name: 'NCS?'), |
|
|
55 |
(code: $E500; Name: 'Epoch?'), (code: $CB00; Name: 'VAP?'), (code: $8C00; |
|
|
56 |
Name: 'Vic Tokai'), |
|
|
57 |
(code: $C200; Name: 'Kemco?'), (code: $BF00; Name: 'Sammy?'), |
|
|
58 |
(code: $1800; Name: 'Hudson Soft'), (code: $CA01; Name: 'Palcom/Ultra'), |
|
|
59 |
(code: $CA00; Name: 'Palcom/Ultra'), (code: $C500; Name: 'Data East?'), |
|
|
60 |
(code: $A900; Name: 'Technos Japan?'), (code: $D900; Name: 'Banpresto?'), |
|
|
61 |
(code: $7201; Name: 'Broderbund?'), (code: $7A01; Name: 'Triffix Entertainment?'), |
|
|
62 |
(code: $E100; Name: 'Towachiki?'), (code: $9300; Name: 'Tsuburava?'), |
|
|
63 |
(code: $C600; Name: 'Tonkin House?'), (code: $CE00; Name: 'Pony Canyon'), |
|
|
64 |
(code: $7001; Name: 'Infogrames?'), (code: $8B01; Name: 'Bullet-Proof Software?'), |
|
|
65 |
(code: $5501; Name: 'Park Place?'), (code: $EA00; Name: 'King Records?'), |
|
|
66 |
(code: $5D01; Name: 'Tradewest?'), (code: $6F01; Name: 'ElectroBrain?'), |
|
|
67 |
(code: $AA01; Name: 'Broderbund?'), (code: $C301; Name: 'SquareSoft'), |
|
|
68 |
(code: $5201; Name: 'Activision?'), (code: $5A01; Name: 'Bitmap Brothers/Mindscape'), |
|
|
69 |
(code: $5301; Name: 'American Sammy'), (code: $4701; Name: 'Spectrum Holobyte'), |
|
|
70 |
(code: $1801; Name: 'Hudson Soft')); |
| 49 |
|
71 |
|
| 50 |
|
72 |
|
| 51 |
{+ Wichtig !! die beiden Speicherfunktionen müssen |
73 |
{+ Wichtig !! die beiden Speicherfunktionen müssen |
| 52 |
unbedingt CDECL deklariert sein !!! +} |
74 |
unbedingt CDECL deklariert sein !!! +} |
| 53 |
|
75 |
|
| 54 |
function speekb(address:Word):Byte;cdecl; |
76 |
function speekb(address: word): byte; cdecl; |
| 55 |
procedure spokeb(address:WORD;data:byte);cdecl; |
77 |
procedure spokeb(address: word; Data: byte); cdecl; |
| 56 |
|
78 |
|
| 57 |
function wordpeek(Addr:Word):Word; |
79 |
function wordpeek(Addr: word): word; |
| 58 |
procedure wordpoke(addr:Word;val:Word); |
80 |
procedure wordpoke(addr: word; val: word); |
| 59 |
procedure push_pc; |
81 |
procedure push_pc; |
| 60 |
|
82 |
|
| 61 |
procedure set_bank(number:DWORD); |
83 |
procedure set_bank(number: DWORD); |
| 62 |
procedure set_bank_mbc1_hi(data:DWORD); |
84 |
procedure set_bank_mbc1_hi(Data: DWORD); |
| 63 |
procedure set_bank_mbc1_lo(data:DWORD); |
85 |
procedure set_bank_mbc1_lo(Data: DWORD); |
| 64 |
procedure set_bank_mbc5_lo(data:DWORD); |
86 |
procedure set_bank_mbc5_lo(Data: DWORD); |
| 65 |
procedure set_bank_mbc5_hi(data:DWORD); |
87 |
procedure set_bank_mbc5_hi(Data: DWORD); |
| 66 |
procedure set_ff0f(number:Byte); |
88 |
procedure set_ff0f(number: byte); |
| 67 |
function getcompany:String; |
89 |
function getcompany: string; |
| 68 |
implementation uses vars,sound; |
90 |
|
| 69 |
|
91 |
implementation |
| 70 |
function getCompany:String; |
92 |
|
| 71 |
var j:word; |
93 |
uses vars, sound; |
| 72 |
i:integer; |
94 |
|
|
|
95 |
function getCompany: string; |
|
|
96 |
var |
|
|
97 |
j: word; |
|
|
98 |
i: integer; |
| 73 |
begin |
99 |
begin |
| 74 |
if cart=nil then exit; |
100 |
if cart = nil then |
| 75 |
J:=byte(pchar(cart)[$014B]) shl 8+byte(pchar(cart)[$014A]); |
101 |
exit; |
| 76 |
for I:=low(companies) to high(companies) do |
102 |
J := byte(PChar(cart)[$014B]) shl 8 + byte(PChar(cart)[$014A]); |
| 77 |
if Companies[I].Code=J then |
103 |
for I := low(companies) to high(companies) do |
| 78 |
begin |
104 |
if Companies[I].Code = J then |
| 79 |
result:=Companies[I].Name;exit; |
105 |
begin |
| 80 |
end; |
106 |
Result := Companies[I].Name; |
| 81 |
result:=''; |
107 |
exit; |
|
|
108 |
end; |
|
|
109 |
Result := ''; |
| 82 |
end; |
110 |
end; |
| 83 |
procedure set_bank(number:DWORD); |
111 |
|
|
|
112 |
procedure set_bank(number: DWORD); |
| 84 |
begin |
113 |
begin |
| 85 |
if number=0 then number:=1; |
114 |
if number = 0 then |
| 86 |
number:=number mod srom; |
115 |
number := 1; |
| 87 |
if number=0 then number:=1; |
116 |
number := number mod srom; |
| 88 |
addr_bank:=number*$4000-$4000; |
117 |
if number = 0 then |
|
|
118 |
number := 1; |
|
|
119 |
addr_bank := number * $4000 - $4000; |
| 89 |
end; |
120 |
end; |
| 90 |
|
121 |
|
| 91 |
procedure set_bank_mbc1_hi(data:DWord); |
122 |
procedure set_bank_mbc1_hi(Data: DWord); |
| 92 |
begin |
123 |
begin |
| 93 |
data:=(data and 3) shl 5; |
124 |
Data := (Data and 3) shl 5; |
| 94 |
rom_priv:=(rom_priv and 31) or Data; |
125 |
rom_priv := (rom_priv and 31) or Data; |
| 95 |
set_bank(rom_priv); |
126 |
set_bank(rom_priv); |
| 96 |
end; |
127 |
end; |
| 97 |
|
128 |
|
| 98 |
procedure set_bank_mbc1_lo(data:Dword); |
129 |
procedure set_bank_mbc1_lo(Data: Dword); |
| 99 |
begin |
130 |
begin |
| 100 |
rom_priv:=(rom_priv and 96) or data; |
131 |
rom_priv := (rom_priv and 96) or Data; |
| 101 |
set_bank(rom_priv); |
132 |
set_bank(rom_priv); |
| 102 |
end; |
133 |
end; |
| 103 |
|
134 |
|
| 104 |
procedure set_bank_mbc5_lo(data:DWORD); |
135 |
procedure set_bank_mbc5_lo(Data: DWORD); |
| 105 |
begin |
136 |
begin |
| 106 |
rom_priv:=(rom_priv and 256) or data; |
137 |
rom_priv := (rom_priv and 256) or Data; |
| 107 |
set_bank(rom_priv); |
138 |
set_bank(rom_priv); |
| 108 |
end; |
139 |
end; |
| 109 |
|
140 |
|
| 110 |
procedure set_bank_mbc5_hi(data:Dword); |
141 |
procedure set_bank_mbc5_hi(Data: Dword); |
| 111 |
begin |
142 |
begin |
| 112 |
if(data and 1>0) then rom_priv:=rom_priv or 256 |
143 |
if (Data and 1 > 0) then |
|
|
144 |
rom_priv := rom_priv or 256 |
| 113 |
else |
145 |
else |
| 114 |
rom_priv:=rom_priv and 255; |
146 |
rom_priv := rom_priv and 255; |
| 115 |
set_bank(rom_priv); |
147 |
set_bank(rom_priv); |
| 116 |
end; |
148 |
end; |
| 117 |
|
149 |
|
| 118 |
procedure set_ff0f(number:Byte); |
150 |
procedure set_ff0f(number: byte); |
| 119 |
(* |
151 |
(* |
| 120 |
|
152 |
|
| 121 |
FF0F - IFLAGS [RW] Interrupt Flags |
153 |
FF0F - IFLAGS [RW] Interrupt Flags |
@@ -131,430 +163,520 @@ Bit0 LCD vertical blanking impulse | ENABLED | DISABLED |
| 131 |
|
163 |
|
| 132 |
*) |
164 |
*) |
| 133 |
begin |
165 |
begin |
| 134 |
if m_iram[$ffff] and number>0 then |
166 |
if m_iram[$ffff] and number > 0 then |
| 135 |
m_iram[$ff0f]:=m_iram[$ff0f] or number; |
167 |
m_iram[$ff0f] := m_iram[$ff0f] or number; |
| 136 |
end; |
168 |
end; |
| 137 |
|
169 |
|
| 138 |
|
170 |
|
| 139 |
|
171 |
|
| 140 |
function wordpeek(Addr:Word):Word; |
172 |
function wordpeek(Addr: word): word; |
| 141 |
begin |
173 |
begin |
| 142 |
result:=((speekb((addr)+1) shl 8) or speekb(addr)); |
174 |
Result := ((speekb((addr) + 1) shl 8) or speekb(addr)); |
| 143 |
end; |
175 |
end; |
| 144 |
|
176 |
|
| 145 |
procedure wordpoke(addr:Word;val:Word); |
177 |
procedure wordpoke(addr: word; val: word); |
| 146 |
begin |
178 |
begin |
| 147 |
spokeb(addr, LO(val));spokeb(addr + 1, HI(val)); |
179 |
spokeb(addr, LO(val)); |
|
|
180 |
spokeb(addr + 1, HI(val)); |
| 148 |
end; |
181 |
end; |
| 149 |
|
182 |
|
| 150 |
function speekb(address:Word):Byte; |
183 |
function speekb(address: word): byte; |
| 151 |
var cr,res:byte; |
184 |
var |
|
|
185 |
cr, res: byte; |
| 152 |
begin |
186 |
begin |
| 153 |
if cart=NIL then begin result:=0;exit;end; |
187 |
if cart = nil then |
| 154 |
if address<$8000 then |
188 |
begin |
| 155 |
begin |
189 |
Result := 0; |
| 156 |
if (memc=ROM) or (address<$4000) then |
190 |
exit; |
| 157 |
res:=byte(pchar(cart)[address]) |
191 |
end; |
| 158 |
else |
192 |
if address < $8000 then |
| 159 |
res:=byte(pchar(cart)[address+addr_bank]); |
193 |
begin |
| 160 |
|
194 |
if (memc = ROM) or (address < $4000) then |
| 161 |
asm mov al,res;end;result:=res;exit; |
195 |
res := byte(PChar(cart)[address]) |
| 162 |
// Problem mit cdecl, keine Registerübergabe !! |
196 |
else |
| 163 |
end; |
197 |
res := byte(PChar(cart)[address + addr_bank]); |
| 164 |
|
198 |
|
| 165 |
if (address>=$e000) and (address<$fe00) then dec(address,$2000); |
199 |
asm |
| 166 |
|
200 |
MOV AL,res; |
| 167 |
if gb_mode=CGB then |
201 |
end; |
| 168 |
begin |
202 |
Result := res; |
| 169 |
if (m_iram[$ff4f] and 1>0) and (address>=$8000) and (address<$a000) then |
203 |
exit; |
| 170 |
begin |
204 |
// Problem mit cdecl, keine Registerübergabe !! |
| 171 |
res:=m_iram2[address]; |
205 |
end; |
| 172 |
asm mov al,res;end; result:=res;exit; |
206 |
|
| 173 |
end; |
207 |
if (address >= $e000) and (address < $fe00) then |
| 174 |
if (address>=$d000) and (address<=$dfff) then |
208 |
Dec(address, $2000); |
| 175 |
begin |
209 |
|
| 176 |
cr:=(m_iram[$ff70]) and 7; |
210 |
if gb_mode = CGB then |
| 177 |
if cr=0 then cr:=1; |
211 |
begin |
| 178 |
res:=m_cgbram[4096*cr+address-$d000]; |
212 |
if (m_iram[$ff4f] and 1 > 0) and (address >= $8000) and (address < $a000) then |
| 179 |
asm mov al,res; end; result:=res;exit; |
213 |
begin |
| 180 |
end; |
214 |
res := m_iram2[address]; |
| 181 |
|
215 |
asm |
| 182 |
case address of |
216 |
MOV AL,res; |
| 183 |
$ff26: begin // sound |
217 |
end; |
| 184 |
m_iram[$ff26]:=(m_iram[$ff26] and $f0) or (byte(snd[4].Enable) shl 3) or |
218 |
Result := res; |
| 185 |
(byte(snd[3].Enable) shl 2) or (byte(snd[2].Enable) shl 1) or byte(snd[1].Enable); |
219 |
exit; |
| 186 |
res:=m_iram[$ff26]; |
220 |
end; |
| 187 |
asm mov al,res end; result:=res; |
221 |
if (address >= $d000) and (address <= $dfff) then |
|
|
222 |
begin |
|
|
223 |
cr := (m_iram[$ff70]) and 7; |
|
|
224 |
if cr = 0 then |
|
|
225 |
cr := 1; |
|
|
226 |
res := m_cgbram[4096 * cr + address - $d000]; |
|
|
227 |
asm |
|
|
228 |
MOV AL,res; |
|
|
229 |
end; |
|
|
230 |
Result := res; |
|
|
231 |
exit; |
|
|
232 |
end; |
|
|
233 |
|
|
|
234 |
case address of |
|
|
235 |
$ff26: |
|
|
236 |
begin // sound |
|
|
237 |
m_iram[$ff26] := (m_iram[$ff26] and $f0) or (byte(snd[4].Enable) shl 3) or |
|
|
238 |
(byte(snd[3].Enable) shl 2) or (byte(snd[2].Enable) shl 1) or |
|
|
239 |
byte(snd[1].Enable); |
|
|
240 |
res := m_iram[$ff26]; |
|
|
241 |
asm |
|
|
242 |
MOV AL,res end; |
|
|
243 |
Result := res; |
|
|
244 |
end; |
|
|
245 |
$ff69: |
|
|
246 |
begin |
|
|
247 |
res := palramb[(m_iram[$ff68]) and 63]; |
|
|
248 |
asm |
|
|
249 |
MOV AL,res; |
| 188 |
end; |
250 |
end; |
| 189 |
$ff69: begin |
251 |
Result := res; |
| 190 |
res:=palramb[(m_iram[$ff68]) and 63]; |
252 |
exit; |
| 191 |
asm mov al,res; end; result:=res;exit; |
253 |
end; |
| 192 |
end; |
254 |
$ff6b: |
| 193 |
$ff6b: begin |
255 |
begin |
| 194 |
res:=palramo[(m_iram[$ff68]) and 63]; |
256 |
res := palramo[(m_iram[$ff68]) and 63]; |
| 195 |
asm mov al,res; end; result:=res;exit; |
257 |
asm |
| 196 |
end; |
258 |
MOV AL,res; |
| 197 |
end; // case |
259 |
end; |
| 198 |
end; // end CGB |
260 |
Result := res; |
|
|
261 |
exit; |
|
|
262 |
end; |
|
|
263 |
end; // case |
|
|
264 |
end; // end CGB |
| 199 |
|
265 |
|
| 200 |
|
266 |
|
| 201 |
if (sram>0) and ((address>=$a000) and (address<$c000)) then |
267 |
if (sram > 0) and ((address >= $a000) and (address < $c000)) then |
| 202 |
begin |
268 |
begin |
| 203 |
res:=m_ram[address-$a000+n_ram*$8912]; |
269 |
res := m_ram[address - $a000 + n_ram * $8912]; |
| 204 |
asm mov al,res; end; result:=res;exit; |
270 |
asm |
| 205 |
end; |
271 |
MOV AL,res; |
|
|
272 |
end; |
|
|
273 |
Result := res; |
|
|
274 |
exit; |
|
|
275 |
end; |
| 206 |
|
276 |
|
| 207 |
res:=m_iram[address]; |
277 |
res := m_iram[address]; |
| 208 |
asm mov al,res; end; result:=res; |
278 |
asm |
|
|
279 |
MOV AL,res; |
|
|
280 |
end; |
|
|
281 |
Result := res; |
| 209 |
end; |
282 |
end; |
| 210 |
|
283 |
|
| 211 |
procedure spokeb(address:WORD;data:byte);cdecl; // neu |
284 |
procedure spokeb(address: word; Data: byte); cdecl; // neu |
| 212 |
var cr:byte; |
285 |
var |
| 213 |
ji,pi:longint; |
286 |
cr: byte; |
| 214 |
sAddr,Offset:Word; |
287 |
ji, pi: longint; |
| 215 |
templ,tempr:Byte; |
288 |
sAddr, Offset: word; |
|
|
289 |
templ, tempr: byte; |
| 216 |
|
290 |
|
| 217 |
begin |
291 |
begin |
| 218 |
if cart=NIL then exit; |
292 |
if cart = nil then |
| 219 |
if (address<$8000) then |
293 |
exit; |
| 220 |
begin |
294 |
if (address < $8000) then |
| 221 |
case memc of |
295 |
begin |
| 222 |
MBC3: begin |
296 |
case memc of |
| 223 |
if((address>=$2000) and (address<=$3fff)) then |
297 |
MBC3: |
| 224 |
begin |
298 |
begin |
| 225 |
if(data=0) then data:=1; |
299 |
if ((address >= $2000) and (address <= $3fff)) then |
| 226 |
set_bank(data); |
300 |
begin |
| 227 |
exit; |
301 |
if (Data = 0) then |
| 228 |
end else |
302 |
Data := 1; |
| 229 |
if ((address>=$4000) and (address<$6000)) then |
303 |
set_bank(Data); |
| 230 |
begin |
304 |
exit; |
| 231 |
n_ram:=data and 3; |
305 |
end |
| 232 |
exit; |
306 |
else |
| 233 |
end; |
307 |
if ((address >= $4000) and (address < $6000)) then |
| 234 |
end; |
308 |
begin |
| 235 |
MBC1: begin |
309 |
n_ram := Data and 3; |
| 236 |
if((address>=$6000) and (address<$8000)) then |
310 |
exit; |
| 237 |
begin |
311 |
end; |
| 238 |
mbc1_type:=data and 1; |
312 |
end; |
| 239 |
exit; |
313 |
MBC1: |
| 240 |
end |
314 |
begin |
| 241 |
else |
315 |
if ((address >= $6000) and (address < $8000)) then |
| 242 |
if((address>=$2000) and (address<$4000)) then |
316 |
begin |
| 243 |
begin |
317 |
mbc1_type := Data and 1; |
| 244 |
data:=data and 31; |
318 |
exit; |
| 245 |
set_bank_mbc1_lo(data); |
319 |
end |
| 246 |
exit; |
320 |
else |
| 247 |
end else |
321 |
if ((address >= $2000) and (address < $4000)) then |
| 248 |
if((address>=$4000) and (address<$6000)) then |
322 |
begin |
|
|
323 |
Data := Data and 31; |
|
|
324 |
set_bank_mbc1_lo(Data); |
|
|
325 |
exit; |
|
|
326 |
end |
|
|
327 |
else |
|
|
328 |
if ((address >= $4000) and (address < $6000)) then |
|
|
329 |
begin |
|
|
330 |
if mbc1_type > 0 then |
| 249 |
begin |
331 |
begin |
| 250 |
if mbc1_type>0 then |
332 |
n_ram := Data and 3; |
| 251 |
begin |
|
|
| 252 |
n_ram:=data and 3; |
|
|
| 253 |
exit; |
333 |
exit; |
| 254 |
end; |
|
|
| 255 |
end |
|
|
| 256 |
else |
|
|
| 257 |
begin |
|
|
| 258 |
set_bank_mbc1_hi(data); |
|
|
| 259 |
exit; |
|
|
| 260 |
end; |
334 |
end; |
| 261 |
end; |
335 |
end |
| 262 |
MBC5: begin |
336 |
else |
| 263 |
if((address>=$2000) and (address<=$2fff)) then |
|
|
| 264 |
begin |
337 |
begin |
| 265 |
set_bank_mbc5_lo(data); |
338 |
set_bank_mbc1_hi(Data); |
| 266 |
exit; |
339 |
exit; |
| 267 |
end; |
340 |
end; |
| 268 |
if((address>=$3000) and (address<=$3fff)) then |
341 |
end; |
|
|
342 |
MBC5: |
|
|
343 |
begin |
|
|
344 |
if ((address >= $2000) and (address <= $2fff)) then |
| 269 |
begin |
345 |
begin |
| 270 |
set_bank_mbc5_hi(data); |
346 |
set_bank_mbc5_lo(Data); |
| 271 |
exit; |
347 |
exit; |
| 272 |
end; |
348 |
end; |
| 273 |
if((address>=$4000) and (address<=$5fff)) then |
349 |
if ((address >= $3000) and (address <= $3fff)) then |
| 274 |
begin |
350 |
begin |
| 275 |
n_ram:=data and 15; |
351 |
set_bank_mbc5_hi(Data); |
| 276 |
exit; |
352 |
exit; |
| 277 |
end; |
353 |
end; |
|
|
354 |
if ((address >= $4000) and (address <= $5fff)) then |
|
|
355 |
begin |
|
|
356 |
n_ram := Data and 15; |
|
|
357 |
exit; |
| 278 |
end; |
358 |
end; |
| 279 |
MBC2: begin |
359 |
end; |
| 280 |
if((address>=$2000) and (address<$4000) and (address and 256>0)) then |
360 |
MBC2: |
|
|
361 |
begin |
|
|
362 |
if ((address >= $2000) and (address < $4000) and (address and 256 > 0)) then |
| 281 |
begin |
363 |
begin |
| 282 |
data:=data and 15; |
364 |
Data := Data and 15; |
| 283 |
set_bank(data); |
365 |
set_bank(Data); |
| 284 |
exit; |
366 |
exit; |
| 285 |
end; |
367 |
end; |
| 286 |
end; |
368 |
end; |
|
|
369 |
end; |
| 287 |
end; |
370 |
end; |
| 288 |
end; |
|
|
| 289 |
|
371 |
|
| 290 |
|
372 |
|
| 291 |
if gb_mode=CGB then |
373 |
if gb_mode = CGB then |
| 292 |
begin |
|
|
| 293 |
if ((address>=$d000) and (address<=$dfff)) then |
|
|
| 294 |
begin |
|
|
| 295 |
cr:=(m_iram[$ff70]) and 7; |
|
|
| 296 |
if(cr=0) then cr:=1; |
|
|
| 297 |
m_cgbram[4096*cr+address-$d000]:=data; |
|
|
| 298 |
exit; |
|
|
| 299 |
end; |
|
|
| 300 |
|
|
|
| 301 |
if (address=$ff55) then |
|
|
| 302 |
begin |
374 |
begin |
| 303 |
if(data and 128=0) then |
375 |
if ((address >= $d000) and (address <= $dfff)) then |
| 304 |
begin |
376 |
begin |
| 305 |
if hdma>0 then hdma:=0 else |
377 |
cr := (m_iram[$ff70]) and 7; |
|
|
378 |
if (cr = 0) then |
|
|
379 |
cr := 1; |
|
|
380 |
m_cgbram[4096 * cr + address - $d000] := Data; |
|
|
381 |
exit; |
|
|
382 |
end; |
|
|
383 |
|
|
|
384 |
if (address = $ff55) then |
|
|
385 |
begin |
|
|
386 |
if (Data and 128 = 0) then |
|
|
387 |
begin |
|
|
388 |
if hdma > 0 then |
|
|
389 |
hdma := 0 |
|
|
390 |
else |
| 306 |
begin |
391 |
begin |
| 307 |
adr_s:=((m_iram[$ff51]) shl 8) or (m_iram[$ff52] and 240); |
392 |
adr_s := ((m_iram[$ff51]) shl 8) or (m_iram[$ff52] and 240); |
| 308 |
adr_p:=((((m_iram[$ff53]) and 31) shl 8) or (m_iram[$ff54] and 240)) or $8000; |
393 |
adr_p := ((((m_iram[$ff53]) and 31) shl 8) or (m_iram[$ff54] and 240)) or $8000; |
| 309 |
for ji:=0 to ((data and 127)*16+16)-1 do |
394 |
for ji := 0 to ((Data and 127) * 16 + 16) - 1 do |
| 310 |
begin |
395 |
begin |
| 311 |
spokeb(adr_p,speekb(adr_s)); |
396 |
spokeb(adr_p, speekb(adr_s)); |
| 312 |
inc(adr_p);inc(adr_s); |
397 |
Inc(adr_p); |
|
|
398 |
Inc(adr_s); |
| 313 |
end; |
399 |
end; |
| 314 |
inc(cnumber,data*32+928 div gb_speed); |
400 |
Inc(cnumber, Data * 32 + 928 div gb_speed); |
| 315 |
data:=$ff; |
401 |
Data := $ff; |
| 316 |
end |
402 |
end; |
| 317 |
end |
403 |
end |
| 318 |
else |
404 |
else |
| 319 |
begin |
405 |
begin |
| 320 |
data:=data and 127; |
406 |
Data := Data and 127; |
| 321 |
if(m_iram[$ff40] and 128>0) then |
407 |
if (m_iram[$ff40] and 128 > 0) then |
| 322 |
begin |
408 |
begin |
| 323 |
hdma:=1; |
409 |
hdma := 1; |
| 324 |
hdma_count:=data+1; |
410 |
hdma_count := Data + 1; |
| 325 |
adr_s:=((m_iram[$ff51]) shl 8) or (m_iram[$ff52] and 240); |
411 |
adr_s := ((m_iram[$ff51]) shl 8) or (m_iram[$ff52] and 240); |
| 326 |
adr_p:=((((m_iram[$ff53]) and 31) shl 8) or (m_iram[$ff54] and 240)) or $8000; |
412 |
adr_p := ((((m_iram[$ff53]) and 31) shl 8) or (m_iram[$ff54] and 240)) or $8000; |
| 327 |
end; |
413 |
end; |
| 328 |
end; |
414 |
end; |
| 329 |
end; |
415 |
end; |
| 330 |
|
416 |
|
| 331 |
|
417 |
|
| 332 |
if((address>=$8000) and (address<$a000) and ((m_iram[$ff4f] and 1>0))) then |
418 |
if ((address >= $8000) and (address < $a000) and ((m_iram[$ff4f] and 1 > 0))) then |
| 333 |
begin |
419 |
begin |
| 334 |
m_iram2[address]:=data; |
420 |
m_iram2[address] := Data; |
| 335 |
exit; |
421 |
exit; |
| 336 |
end; |
422 |
end; |
| 337 |
|
423 |
|
| 338 |
case address of |
424 |
case address of |
| 339 |
$ff69: begin |
425 |
$ff69: |
| 340 |
palramb[(m_iram[$ff68]) and 63]:=data; |
426 |
begin |
| 341 |
if(m_iram[$ff68] and 1)>0 then |
427 |
palramb[(m_iram[$ff68]) and 63] := Data; |
| 342 |
begin |
428 |
if (m_iram[$ff68] and 1) > 0 then |
| 343 |
tempL:=((m_iram[$ff68]) and 56) shr 3; |
429 |
begin |
| 344 |
tempR:=((m_iram[$ff68]) and 6) shr 1; |
430 |
tempL := ((m_iram[$ff68]) and 56) shr 3; |
| 345 |
pal_b[templ][tempr][0]:=(data and 124) shl 1; |
431 |
tempR := ((m_iram[$ff68]) and 6) shr 1; |
| 346 |
pal_b[templ][tempr][1]:=pal_b[templ][tempr][1] and 63; |
432 |
pal_b[templ][tempr][0] := (Data and 124) shl 1; |
| 347 |
pal_b[templ][tempr][1]:=pal_b[templ][tempr][1] or (data shl 6); |
433 |
pal_b[templ][tempr][1] := pal_b[templ][tempr][1] and 63; |
| 348 |
end |
434 |
pal_b[templ][tempr][1] := pal_b[templ][tempr][1] or (Data shl 6); |
| 349 |
else |
435 |
end |
| 350 |
begin |
436 |
else |
| 351 |
templ:=((m_iram[$ff68]) and 56) shr 3; |
437 |
begin |
| 352 |
tempr:=((m_iram[$ff68]) and 6) shr 1; |
438 |
templ := ((m_iram[$ff68]) and 56) shr 3; |
|
|
439 |
tempr := ((m_iram[$ff68]) and 6) shr 1; |
| 353 |
|
440 |
|
| 354 |
pal_b[templ][tempr][2]:=(data and 31) shl 3; |
441 |
pal_b[templ][tempr][2] := (Data and 31) shl 3; |
| 355 |
pal_b[templ][tempr][1]:=pal_b[templ][tempr][1] and 192; |
442 |
pal_b[templ][tempr][1] := pal_b[templ][tempr][1] and 192; |
| 356 |
pal_b[templ][tempr][1]:=pal_b[templ][tempr][1] or ((data and 224) shr 2); |
443 |
pal_b[templ][tempr][1] := pal_b[templ][tempr][1] or ((Data and 224) shr 2); |
| 357 |
end; |
444 |
end; |
| 358 |
|
445 |
|
| 359 |
pal_dx_b[((m_iram[$ff68]) and 56) shr 3][((m_iram[$ff68]) and 6) shr 1]:= |
446 |
pal_dx_b[((m_iram[$ff68]) and 56) shr 3][((m_iram[$ff68]) and 6) shr 1] := |
| 360 |
(((pal_b[((m_iram[$ff68]) and 56) shr 3][((m_iram[$ff68]) and 6) shr 1][2]) shr (8-dx_r)) shl dx_sr) or (((pal_b[((m_iram[$ff68]) and 56) shr 3][((m_iram[$ff68]) and 6) shr 1][1]) shr (8-dx_g)) shl dx_sg) or (((pal_b[((m_iram[$ff68]) and 56) shr 3][((m_iram[$ff68]) and 6) shr 1][0]) shr (8-dx_b)) shl dx_sb); |
447 |
(((pal_b[((m_iram[$ff68]) and 56) shr 3][((m_iram[$ff68]) and 6) shr 1][2]) shr |
| 361 |
if(m_iram[$ff68] and 128)>0 then |
448 |
(8 - dx_r)) shl dx_sr) or (((pal_b[((m_iram[$ff68]) and 56) shr 3][ |
|
|
449 |
((m_iram[$ff68]) and 6) shr 1][1]) shr (8 - dx_g)) shl dx_sg) or |
|
|
450 |
(((pal_b[((m_iram[$ff68]) and 56) shr 3][((m_iram[$ff68]) and 6) shr 1][0]) shr |
|
|
451 |
(8 - dx_b)) shl dx_sb); |
|
|
452 |
if (m_iram[$ff68] and 128) > 0 then |
| 362 |
begin |
453 |
begin |
| 363 |
m_iram[$ff68]:=m_iram[$ff68] and $3f; |
454 |
m_iram[$ff68] := m_iram[$ff68] and $3f; |
| 364 |
inc(m_iram[$ff68]); |
455 |
Inc(m_iram[$ff68]); |
| 365 |
m_iram[$ff68]:=m_iram[$ff68] or 128; |
456 |
m_iram[$ff68] := m_iram[$ff68] or 128; |
| 366 |
end; |
457 |
end; |
| 367 |
end; |
458 |
end; |
| 368 |
$ff6b: begin |
459 |
$ff6b: |
| 369 |
palramo[(m_iram[$ff6a]) and 63]:=data; |
460 |
begin |
| 370 |
if(m_iram[$ff6a] and 1)>0 then |
461 |
palramo[(m_iram[$ff6a]) and 63] := Data; |
| 371 |
begin |
462 |
if (m_iram[$ff6a] and 1) > 0 then |
| 372 |
templ:=((m_iram[$ff6a]) and 56) shr 3; |
463 |
begin |
| 373 |
tempr:=((m_iram[$ff6a]) and 6) shr 1; |
464 |
templ := ((m_iram[$ff6a]) and 56) shr 3; |
| 374 |
|
465 |
tempr := ((m_iram[$ff6a]) and 6) shr 1; |
| 375 |
pal_o[templ][tempr][0]:=(data and 124) shl 1; |
|
|
| 376 |
pal_o[templ][tempr][1]:=pal_o[templ][tempr][1] and 63; |
|
|
| 377 |
pal_o[templ][tempr][1]:=pal_o[templ][tempr][1] or (data shl 6); |
|
|
| 378 |
end |
|
|
| 379 |
else |
|
|
| 380 |
begin |
|
|
| 381 |
templ:=((m_iram[$ff6a]) and 56) shr 3; |
|
|
| 382 |
tempr:=((m_iram[$ff6a]) and 6) shr 1; |
|
|
| 383 |
|
|
|
| 384 |
pal_o[templ][tempr][2]:=(data and 31) shl 3; |
|
|
| 385 |
pal_o[templ][tempr][1]:=pal_o[templ][tempr][1] and 192; |
|
|
| 386 |
pal_o[templ][tempr][1]:=pal_o[templ][tempr][1] or ((data and 224) shr 2); |
|
|
| 387 |
end; |
|
|
| 388 |
pal_dx_o[((m_iram[$ff6a]) and 56) shr 3][((m_iram[$ff6a]) and 6) shr 1]:=(((pal_o[((m_iram[$ff6a]) and 56) shr 3][((m_iram[$ff6a]) and 6) shr 1][2]) shr (8-dx_r)) shl dx_sr) or (((pal_o[((m_iram[$ff6a]) and 56) shr 3][((m_iram[$ff6a]) and 6) shr 1][1]) shr (8-dx_g)) shl dx_sg) or (((pal_o[((m_iram[$ff6a]) and 56) shr 3][((m_iram[$ff6a]) and 6) shr 1][0]) shr (8-dx_b)) shl dx_sb); |
|
|
| 389 |
if(m_iram[$ff6a] and 128)>0 then |
|
|
| 390 |
begin |
|
|
| 391 |
m_iram[$ff6a]:=m_iram[$ff6a] and $3f; |
|
|
| 392 |
inc(m_iram[$ff6a]); |
|
|
| 393 |
m_iram[$ff6a]:=m_iram[$ff6a] or 128; |
|
|
| 394 |
end; |
|
|
| 395 |
end; |
|
|
| 396 |
end; |
|
|
| 397 |
end; |
|
|
| 398 |
|
466 |
|
| 399 |
if ((address>=$e000) and (address<$fe00)) then dec(address,$2000); |
467 |
pal_o[templ][tempr][0] := (Data and 124) shl 1; |
|
|
468 |
pal_o[templ][tempr][1] := pal_o[templ][tempr][1] and 63; |
|
|
469 |
pal_o[templ][tempr][1] := pal_o[templ][tempr][1] or (Data shl 6); |
|
|
470 |
end |
|
|
471 |
else |
|
|
472 |
begin |
|
|
473 |
templ := ((m_iram[$ff6a]) and 56) shr 3; |
|
|
474 |
tempr := ((m_iram[$ff6a]) and 6) shr 1; |
| 400 |
|
475 |
|
| 401 |
if (address>=$ff00) then |
476 |
pal_o[templ][tempr][2] := (Data and 31) shl 3; |
| 402 |
begin |
477 |
pal_o[templ][tempr][1] := pal_o[templ][tempr][1] and 192; |
| 403 |
case address of |
478 |
pal_o[templ][tempr][1] := pal_o[templ][tempr][1] or ((Data and 224) shr 2); |
| 404 |
$ff00: begin |
479 |
end; |
| 405 |
if (data=3) then data:=$ff else |
480 |
pal_dx_o[((m_iram[$ff6a]) and 56) shr 3][((m_iram[$ff6a]) and 6) shr 1] := |
| 406 |
if((data and $30)=$30) then data:=$ff |
481 |
(((pal_o[((m_iram[$ff6a]) and 56) shr 3][((m_iram[$ff6a]) and 6) shr 1][2]) shr |
| 407 |
else |
482 |
(8 - dx_r)) shl dx_sr) or (((pal_o[((m_iram[$ff6a]) and 56) shr 3][ |
| 408 |
begin |
483 |
((m_iram[$ff6a]) and 6) shr 1][1]) shr (8 - dx_g)) shl dx_sg) or |
| 409 |
if((data and $30)=$20) then |
484 |
(((pal_o[((m_iram[$ff6a]) and 56) shr 3][((m_iram[$ff6a]) and 6) shr 1][0]) shr |
| 410 |
data:=$20 or (k_down shl 3) or (k_up shl 2) or (k_left shl 1) or k_right |
485 |
(8 - dx_b)) shl dx_sb); |
| 411 |
else |
486 |
if (m_iram[$ff6a] and 128) > 0 then |
| 412 |
if((data and $30)=$10) then |
487 |
begin |
| 413 |
data:=$10 or (k_start shl 3) or (k_select shl 2) or(k_b shl 1) or k_a; |
488 |
m_iram[$ff6a] := m_iram[$ff6a] and $3f; |
| 414 |
end; |
489 |
Inc(m_iram[$ff6a]); |
| 415 |
data:=data or $c0; |
490 |
m_iram[$ff6a] := m_iram[$ff6a] or 128; |
|
|
491 |
end; |
| 416 |
end; |
492 |
end; |
| 417 |
$ff02: begin |
493 |
end; |
| 418 |
if((data and 128>0) and (data and 1>0)) then sio_count:=8; |
494 |
end; |
| 419 |
data:=data or 126; |
495 |
|
| 420 |
end; |
496 |
if ((address >= $e000) and (address < $fe00)) then |
| 421 |
$ff04: begin |
497 |
Dec(address, $2000); |
| 422 |
data:=0; |
498 |
|
| 423 |
n_ff04:=0; |
499 |
if (address >= $ff00) then |
|
|
500 |
begin |
|
|
501 |
case address of |
|
|
502 |
$ff00: |
|
|
503 |
begin |
|
|
504 |
if (Data = 3) then |
|
|
505 |
Data := $ff |
|
|
506 |
else |
|
|
507 |
if ((Data and $30) = $30) then |
|
|
508 |
Data := $ff |
|
|
509 |
else |
|
|
510 |
begin |
|
|
511 |
if ((Data and $30) = $20) then |
|
|
512 |
Data := $20 or (k_down shl 3) or (k_up shl 2) or (k_left shl 1) or k_right |
|
|
513 |
else |
|
|
514 |
if ((Data and $30) = $10) then |
|
|
515 |
Data := $10 or (k_start shl 3) or (k_select shl 2) or (k_b shl 1) or k_a; |
| 424 |
end; |
516 |
end; |
| 425 |
$ff07: begin |
517 |
Data := Data or $c0; |
| 426 |
if(data and 4)>0 then |
518 |
end; |
| 427 |
begin |
519 |
$ff02: |
| 428 |
c_count:=0; |
520 |
begin |
| 429 |
t_count:=m_iram[$ff06]; |
521 |
if ((Data and 128 > 0) and (Data and 1 > 0)) then |
| 430 |
end; |
522 |
sio_count := 8; |
|
|
523 |
Data := Data or 126; |
|
|
524 |
end; |
|
|
525 |
$ff04: |
|
|
526 |
begin |
|
|
527 |
Data := 0; |
|
|
528 |
n_ff04 := 0; |
|
|
529 |
end; |
|
|
530 |
$ff07: |
|
|
531 |
begin |
|
|
532 |
if (Data and 4) > 0 then |
|
|
533 |
begin |
|
|
534 |
c_count := 0; |
|
|
535 |
t_count := m_iram[$ff06]; |
| 431 |
end; |
536 |
end; |
| 432 |
$ff40: begin |
537 |
end; |
| 433 |
if(data and 128=0) then vbioff_count:=1 else |
538 |
$ff40: |
| 434 |
if(m_iram[$ff40] and 128)=0 then |
539 |
begin |
| 435 |
begin |
540 |
if (Data and 128 = 0) then |
| 436 |
old_mode:=5; |
541 |
vbioff_count := 1 |
| 437 |
cycles:=1; |
542 |
else |
| 438 |
cur_c:=2; |
543 |
if (m_iram[$ff40] and 128) = 0 then |
| 439 |
nr_t:=0; |
544 |
begin |
| 440 |
end; |
545 |
old_mode := 5; |
|
|
546 |
cycles := 1; |
|
|
547 |
cur_c := 2; |
|
|
548 |
nr_t := 0; |
| 441 |
end; |
549 |
end; |
| 442 |
$ff0f: begin |
550 |
end; |
| 443 |
if(data and 16)>0 then set_ff0f(16); |
551 |
$ff0f: |
| 444 |
if(data and 8)>0 then set_ff0f(8); |
552 |
begin |
| 445 |
if(data and 4)>0 then set_ff0f(4); |
553 |
if (Data and 16) > 0 then |
| 446 |
if(data and 2)>0 then set_ff0f(2); |
554 |
set_ff0f(16); |
| 447 |
if(data and 1)>0 then set_ff0f(1); |
555 |
if (Data and 8) > 0 then |
|
|
556 |
set_ff0f(8); |
|
|
557 |
if (Data and 4) > 0 then |
|
|
558 |
set_ff0f(4); |
|
|
559 |
if (Data and 2) > 0 then |
|
|
560 |
set_ff0f(2); |
|
|
561 |
if (Data and 1) > 0 then |
|
|
562 |
set_ff0f(1); |
|
|
563 |
end; |
|
|
564 |
$ff10..$ff3F: |
|
|
565 |
begin |
|
|
566 |
sndRegChange := True; |
|
|
567 |
if address = $ff26 then |
|
|
568 |
begin |
|
|
569 |
m_iram[$ff26] := Data; |
|
|
570 |
if Data and $80 = 0 then |
|
|
571 |
begin |
|
|
572 |
snd[1].Enable := False; |
|
|
573 |
snd[2].Enable := False; |
|
|
574 |
snd[3].Enable := False; |
|
|
575 |
snd[4].Enable := False; |
|
|
576 |
end; |
|
|
577 |
exit; |
| 448 |
end; |
578 |
end; |
| 449 |
$ff10..$ff3F: begin |
579 |
m_iram[address] := Data; |
| 450 |
sndRegChange:=true; |
580 |
exit; |
| 451 |
if address=$ff26 then |
581 |
end; |
| 452 |
begin |
582 |
|
| 453 |
m_iram[$ff26]:=data; |
583 |
$ff47: |
| 454 |
if data and $80=0 then |
584 |
begin |
| 455 |
begin |
585 |
if (gb_mode <> CGB) then |
| 456 |
snd[1].Enable:=false; |
586 |
begin |
| 457 |
snd[2].Enable:=false; |
587 |
gb_mode := CGB; |
| 458 |
snd[3].Enable:=false; |
588 |
spokeb($ff68, 128); |
| 459 |
snd[4].Enable:=false; |
589 |
spokeb($ff69, (colors[Data and 3]) and $ff); |
| 460 |
end; |
590 |
spokeb($ff69, (colors[Data and 3]) shr 8); |
| 461 |
exit; |
591 |
spokeb($ff69, (colors[(Data and $c) shr 2]) and $ff); |
| 462 |
end; |
592 |
spokeb($ff69, (colors[(Data and $c) shr 2]) shr 8); |
| 463 |
m_iram[address]:=data; |
593 |
spokeb($ff69, (colors[(Data and $30) shr 4]) and $ff); |
| 464 |
exit; |
594 |
spokeb($ff69, (colors[(Data and $30) shr 4]) shr 8); |
| 465 |
end; |
595 |
spokeb($ff69, (colors[(Data and $c0) shr 6]) and $ff); |
| 466 |
|
596 |
spokeb($ff69, (colors[(Data and $c0) shr 6]) shr 8); |
| 467 |
$ff47: begin |
597 |
gb_mode := DMG; |
| 468 |
if(gb_mode<>CGB) then |
|
|
| 469 |
begin |
|
|
| 470 |
gb_mode:=CGB; |
|
|
| 471 |
spokeb($ff68,128); |
|
|
| 472 |
spokeb($ff69,(colors[data and 3]) and $ff); |
|
|
| 473 |
spokeb($ff69,(colors[data and 3]) shr 8); |
|
|
| 474 |
spokeb($ff69,(colors[(data and $c) shr 2]) and $ff); |
|
|
| 475 |
spokeb($ff69,(colors[(data and $c) shr 2]) shr 8); |
|
|
| 476 |
spokeb($ff69,(colors[(data and $30) shr 4]) and $ff); |
|
|
| 477 |
spokeb($ff69,(colors[(data and $30) shr 4]) shr 8); |
|
|
| 478 |
spokeb($ff69,(colors[(data and $c0) shr 6]) and $ff); |
|
|
| 479 |
spokeb($ff69,(colors[(data and $c0) shr 6]) shr 8); |
|
|
| 480 |
gb_mode:=DMG; |
|
|
| 481 |
end; |
|
|
| 482 |
end; |
598 |
end; |
| 483 |
$ff48: begin |
599 |
end; |
| 484 |
if(gb_mode<>CGB) then |
600 |
$ff48: |
| 485 |
begin |
601 |
begin |
| 486 |
gb_mode:=CGB; |
602 |
if (gb_mode <> CGB) then |
| 487 |
spokeb($ff6a,128); |
603 |
begin |
| 488 |
spokeb($ff6b,(colors[data and 3]) and $ff); |
604 |
gb_mode := CGB; |
| 489 |
spokeb($ff6b,(colors[data and 3]) shr 8); |
605 |
spokeb($ff6a, 128); |
| 490 |
spokeb($ff6b,(colors[(data and $c) shr 2]) and $ff); |
606 |
spokeb($ff6b, (colors[Data and 3]) and $ff); |
| 491 |
spokeb($ff6b,(colors[(data and $c) shr 2]) shr 8); |
607 |
spokeb($ff6b, (colors[Data and 3]) shr 8); |
| 492 |
spokeb($ff6b,(colors[(data and $30) shr 4]) and $ff); |
608 |
spokeb($ff6b, (colors[(Data and $c) shr 2]) and $ff); |
| 493 |
spokeb($ff6b,(colors[(data and $30) shr 4]) shr 8); |
609 |
spokeb($ff6b, (colors[(Data and $c) shr 2]) shr 8); |
| 494 |
spokeb($ff6b,(colors[(data and $c0) shr 6]) and $ff); |
610 |
spokeb($ff6b, (colors[(Data and $30) shr 4]) and $ff); |
| 495 |
spokeb($ff6b,(colors[(data and $c0) shr 6]) shr 8); |
611 |
spokeb($ff6b, (colors[(Data and $30) shr 4]) shr 8); |
| 496 |
gb_mode:=DMG; |
612 |
spokeb($ff6b, (colors[(Data and $c0) shr 6]) and $ff); |
| 497 |
end; |
613 |
spokeb($ff6b, (colors[(Data and $c0) shr 6]) shr 8); |
|
|
614 |
gb_mode := DMG; |
| 498 |
end; |
615 |
end; |
| 499 |
$ff49: begin |
616 |
end; |
| 500 |
if gb_mode<>CGB then |
617 |
$ff49: |
| 501 |
begin |
618 |
begin |
| 502 |
gb_mode:=CGB; |
619 |
if gb_mode <> CGB then |
| 503 |
spokeb($ff6a,128+8); |
620 |
begin |
| 504 |
spokeb($ff6b,(colors[data and 3]) and $ff); |
621 |
gb_mode := CGB; |
| 505 |
spokeb($ff6b,(colors[data and 3]) shr 8); |
622 |
spokeb($ff6a, 128 + 8); |
| 506 |
spokeb($ff6b,(colors[(data and $c) shr 2]) and $ff); |
623 |
spokeb($ff6b, (colors[Data and 3]) and $ff); |
| 507 |
spokeb($ff6b,(colors[(data and $c) shr 2]) shr 8); |
624 |
spokeb($ff6b, (colors[Data and 3]) shr 8); |
| 508 |
spokeb($ff6b,(colors[(data and $30) shr 4]) and $ff); |
625 |
spokeb($ff6b, (colors[(Data and $c) shr 2]) and $ff); |
| 509 |
spokeb($ff6b,(colors[(data and $30) shr 4]) shr 8); |
626 |
spokeb($ff6b, (colors[(Data and $c) shr 2]) shr 8); |
| 510 |
spokeb($ff6b,(colors[(data and $c0) shr 6]) and $ff); |
627 |
spokeb($ff6b, (colors[(Data and $30) shr 4]) and $ff); |
| 511 |
spokeb($ff6b,(colors[(data and $c0) shr 6]) shr 8); |
628 |
spokeb($ff6b, (colors[(Data and $30) shr 4]) shr 8); |
| 512 |
gb_mode:=DMG; |
629 |
spokeb($ff6b, (colors[(Data and $c0) shr 6]) and $ff); |
| 513 |
end; |
630 |
spokeb($ff6b, (colors[(Data and $c0) shr 6]) shr 8); |
|
|
631 |
gb_mode := DMG; |
| 514 |
end; |
632 |
end; |
| 515 |
$ff41: begin |
633 |
end; |
| 516 |
if((mode=0) or (mode=1)) then |
634 |
$ff41: |
| 517 |
begin |
635 |
begin |
| 518 |
m_iram[$ff0f]:=m_iram[$ff0f] or 2; |
636 |
if ((mode = 0) or (mode = 1)) then |
|
|
637 |
begin |
|
|
638 |
m_iram[$ff0f] := m_iram[$ff0f] or 2; |
| 519 |
set_ff0f(2); |
639 |
set_ff0f(2); |
| 520 |
end; |
|
|
| 521 |
end; |
640 |
end; |
| 522 |
$ff46: begin |
641 |
end; |
| 523 |
sAddr:=data shl 8; |
642 |
$ff46: |
| 524 |
Offset:=$fe00; |
643 |
begin |
| 525 |
for pi:=0 to $9f do |
644 |
sAddr := Data shl 8; |
| 526 |
begin |
645 |
Offset := $fe00; |
| 527 |
m_iram[Offset]:=speekb(sAddr); |
646 |
for pi := 0 to $9f do |
| 528 |
inc(Offset);inc(sAddr); |
647 |
begin |
| 529 |
end; |
648 |
m_iram[Offset] := speekb(sAddr); |
|
|
649 |
Inc(Offset); |
|
|
650 |
Inc(sAddr); |
| 530 |
end; |
651 |
end; |
|
|
652 |
end; |
| 531 |
|
653 |
|
| 532 |
end; |
654 |
end; |
| 533 |
end; |
655 |
end; |
| 534 |
|
656 |
|
| 535 |
if(sram>0) and (address>=$a000) and (address<$c000) then |
657 |
if (sram > 0) and (address >= $a000) and (address < $c000) then |
| 536 |
m_ram[address-$a000+n_ram*$8912]:=data |
658 |
m_ram[address - $a000 + n_ram * $8912] := Data |
| 537 |
else |
659 |
else |
| 538 |
m_iram[address]:=data; |
660 |
m_iram[address] := Data; |
| 539 |
end; |
661 |
end; |
| 540 |
|
662 |
|
| 541 |
|
663 |
|
| 542 |
procedure push_pc;assembler; |
664 |
procedure push_pc; assembler; |
| 543 |
asm |
665 |
asm |
| 544 |
mov ax,pc.w |
666 |
MOV AX,pc.w |
| 545 |
dec sp_.w |
667 |
DEC sp_.w |
| 546 |
xchg ah,al |
668 |
XCHG AH,AL |
| 547 |
push eax |
669 |
PUSH EAX |
| 548 |
push dword ptr sp_.w |
670 |
PUSH dword ptr sp_.w |
| 549 |
call spokeb |
671 |
CALL spokeb |
| 550 |
lea esp,[esp+8] |
672 |
LEA ESP,[ESP+8] |
| 551 |
mov ax,pc.w |
673 |
MOV AX,pc.w |
| 552 |
push eax |
674 |
PUSH EAX |
| 553 |
dec sp_.w |
675 |
DEC sp_.w |
| 554 |
push dword ptr sp_.w |
676 |
PUSH dword ptr sp_.w |
| 555 |
call spokeb |
677 |
CALL spokeb |
| 556 |
lea esp,[esp+8] |
678 |
LEA ESP,[ESP+8] |
| 557 |
end; |
679 |
end; |
| 558 |
(* dec(sp_.W,2);wordpoke(sp_.W,pc.w);*) |
680 |
(* dec(sp_.W,2);wordpoke(sp_.W,pc.w);*) |
| 559 |
|
681 |
|
| 560 |
|
682 |
|