Update palette based on AreaType

This commit is contained in:
Lucas Scharenbroich 2023-06-02 21:55:55 -05:00
parent 91454c9481
commit 5acd964917
5 changed files with 400 additions and 41 deletions

View File

@ -38,6 +38,8 @@ CurrNTQueueEnd equ 40
BGToggle equ 44
LastEnable equ 46
LastAreaType equ 48
Tmp0 equ 240
Tmp1 equ 242
Tmp2 equ 244
@ -61,6 +63,7 @@ FTblTmp equ 228
stz ROMScrollEdge
stz ROMScrollDelta
stz OldROMScrollEdge
stz LastAreaType
lda #1
sta BGToggle
@ -128,7 +131,7 @@ FTblTmp equ 228
; pea #144
_GTESetScreenMode
ldx #AreaPalette
ldx #Area1Palette
lda #TmpPalette
jsr NESColorToIIgs
@ -186,9 +189,6 @@ EvtLoop
beq :spin
stz nmiCount
; lda #4
; stal ROMBase+$760
; The GTE playfield is 41 tiles wide, but the NES is 32 tiles wide. Fortunately, the game
; keeps track of the global coordinates of each level at
;
@ -324,6 +324,16 @@ RenderFrame
lsr
sta ROMScreenEdge
; Check the AreaType and see if the palette needs to be changed
ldal ROMBase+$074E
and #$00FF
cmp LastAreaType
beq :no_area_change
sta LastAreaType
jsr SetAreaType
:no_area_change
; Calculate how many blocks have been scrolled into view
lda CurrScrollEdge
@ -365,6 +375,41 @@ RenderFrame
rts
SetAreaType
cmp #5
bcs :out
asl
tay
ldx AreaPalettes,y ; First parameter to NESColorToIIgs
asl
tay
lda SwizzleTables,y
sta SwizzlePtr
lda SwizzleTables+2,y
sta SwizzlePtr+2
lda #TmpPalette
jsr NESColorToIIgs
; Special copy routine; do not touch color indices 0, 1 or 15 -- we let the NES PPU handle those
ldx #4
:loop
lda TmpPalette,x
stal $E19E00,x
inx
inx
cpx #14
bcc :loop
:out
rts
AreaPalettes dw Area1Palette,Area1Palette,Area2Palette,Area3Palette,Area4Palette
SwizzleTables adrl AT1_T0,AT1_T0,AT2_T0,AT2_T0,AT2_T0
SwizzlePtr adrl AT1_T0
; Take a PPU address and convert it to a tile store coordinate
;
; Inputs
@ -1012,6 +1057,13 @@ ConvertROMTile2
sta: 64,x
asl: 2,x
lda: 32,x
jsr reverse4
sta: 98,x
lda: 34,x
jsr reverse4
sta: 96,x
inx
inx
inx
@ -1517,8 +1569,9 @@ PPU_NT ds $2000 ; Nametable memory from $2000 - $3000, $3F00 -
PPU_OAM ds 256 ; 256 bytes of separate OAM RAM
; Palettes of NES color indexes
;AreaPalette dw $0F, $00, $29, $1A, $09, $36, $1C, $30, $21, $16, $27, $18, $17, $3C, $1D, $37
AreaPalette dw $22, $00, $29, $1A, $0F, $36, $17, $30, $21, $16, $27, $18, $1A, $00, $00, $37
Area1Palette dw $22, $00, $29, $1A, $0F, $36, $17, $30, $21, $16, $27, $18, $1A, $00, $00, $37
Area3Palette
Area4Palette
Area2Palette dw $0F, $00, $29, $1A, $09, $3C, $1C, $30, $21, $17, $27, $18, $36, $16, $0C, $16
; Palette remapping
put pal_w11.s

View File

@ -1,19 +1,19 @@
# World 1-1, Underground
#node swizzle.js W11_T0 2 3 4
#node swizzle.js W11_T1 13 6 0
#node swizzle.js W11_T2 7 8 6
#node swizzle.js W11_T3 1 12 6
#node swizzle.js W11_S0 15 10 11
#node swizzle.js W11_S1 6 5 12
#node swizzle.js W11_S2 9 7 10
#node swizzle.js W11_S3 14 13 6
# Area Type $01, Above ground
node swizzle.js AT1_T0 2 3 4
node swizzle.js AT1_T1 5 6 4
node swizzle.js AT1_T2 7 8 4
node swizzle.js AT1_T3 1 6 4
node swizzle.js AT1_S0 15 10 11
node swizzle.js AT1_S1 12 7 10
node swizzle.js AT1_S2 9 7 10
node swizzle.js AT1_S3 4 5 6
# World 1-1, Aboveground
node swizzle.js W11_T0 2 3 4
node swizzle.js W11_T1 5 6 4
node swizzle.js W11_T2 7 8 4
node swizzle.js W11_T3 1 6 4
node swizzle.js W11_S0 15 10 11
node swizzle.js W11_S1 12 7 10
node swizzle.js W11_S2 9 7 10
node swizzle.js W11_S3 4 5 6
# Area Type $02, Underground
node swizzle.js AT2_T0 2 3 4
node swizzle.js AT2_T1 5 6 0
node swizzle.js AT2_T2 7 8 6
node swizzle.js AT2_T3 1 9 6
node swizzle.js AT2_S0 15 10 11
node swizzle.js AT2_S1 6 12 9
node swizzle.js AT2_S2 13 7 10
node swizzle.js AT2_S3 14 5 6

View File

@ -1,4 +1,4 @@
W11_T0
AT1_T0
dw $0000,$0200,$0300,$0400,$2000,$2200,$2300,$2400,$3000,$3200,$3300,$3400,$4000,$4200,$4300,$4400
dw $0002,$0202,$0302,$0402,$2002,$2202,$2302,$2402,$3002,$3202,$3302,$3402,$4002,$4202,$4302,$4402
dw $0003,$0203,$0303,$0403,$2003,$2203,$2303,$2403,$3003,$3203,$3303,$3403,$4003,$4203,$4303,$4403
@ -15,7 +15,7 @@ W11_T0
dw $0042,$0242,$0342,$0442,$2042,$2242,$2342,$2442,$3042,$3242,$3342,$3442,$4042,$4242,$4342,$4442
dw $0043,$0243,$0343,$0443,$2043,$2243,$2343,$2443,$3043,$3243,$3343,$3443,$4043,$4243,$4343,$4443
dw $0044,$0244,$0344,$0444,$2044,$2244,$2344,$2444,$3044,$3244,$3344,$3444,$4044,$4244,$4344,$4444
W11_T1
AT1_T1
dw $0000,$0500,$0600,$0400,$5000,$5500,$5600,$5400,$6000,$6500,$6600,$6400,$4000,$4500,$4600,$4400
dw $0005,$0505,$0605,$0405,$5005,$5505,$5605,$5405,$6005,$6505,$6605,$6405,$4005,$4505,$4605,$4405
dw $0006,$0506,$0606,$0406,$5006,$5506,$5606,$5406,$6006,$6506,$6606,$6406,$4006,$4506,$4606,$4406
@ -32,7 +32,7 @@ W11_T1
dw $0045,$0545,$0645,$0445,$5045,$5545,$5645,$5445,$6045,$6545,$6645,$6445,$4045,$4545,$4645,$4445
dw $0046,$0546,$0646,$0446,$5046,$5546,$5646,$5446,$6046,$6546,$6646,$6446,$4046,$4546,$4646,$4446
dw $0044,$0544,$0644,$0444,$5044,$5544,$5644,$5444,$6044,$6544,$6644,$6444,$4044,$4544,$4644,$4444
W11_T2
AT1_T2
dw $0000,$0700,$0800,$0400,$7000,$7700,$7800,$7400,$8000,$8700,$8800,$8400,$4000,$4700,$4800,$4400
dw $0007,$0707,$0807,$0407,$7007,$7707,$7807,$7407,$8007,$8707,$8807,$8407,$4007,$4707,$4807,$4407
dw $0008,$0708,$0808,$0408,$7008,$7708,$7808,$7408,$8008,$8708,$8808,$8408,$4008,$4708,$4808,$4408
@ -49,7 +49,7 @@ W11_T2
dw $0047,$0747,$0847,$0447,$7047,$7747,$7847,$7447,$8047,$8747,$8847,$8447,$4047,$4747,$4847,$4447
dw $0048,$0748,$0848,$0448,$7048,$7748,$7848,$7448,$8048,$8748,$8848,$8448,$4048,$4748,$4848,$4448
dw $0044,$0744,$0844,$0444,$7044,$7744,$7844,$7444,$8044,$8744,$8844,$8444,$4044,$4744,$4844,$4444
W11_T3
AT1_T3
dw $0000,$0100,$0600,$0400,$1000,$1100,$1600,$1400,$6000,$6100,$6600,$6400,$4000,$4100,$4600,$4400
dw $0001,$0101,$0601,$0401,$1001,$1101,$1601,$1401,$6001,$6101,$6601,$6401,$4001,$4101,$4601,$4401
dw $0006,$0106,$0606,$0406,$1006,$1106,$1606,$1406,$6006,$6106,$6606,$6406,$4006,$4106,$4606,$4406
@ -66,7 +66,7 @@ W11_T3
dw $0041,$0141,$0641,$0441,$1041,$1141,$1641,$1441,$6041,$6141,$6641,$6441,$4041,$4141,$4641,$4441
dw $0046,$0146,$0646,$0446,$1046,$1146,$1646,$1446,$6046,$6146,$6646,$6446,$4046,$4146,$4646,$4446
dw $0044,$0144,$0644,$0444,$1044,$1144,$1644,$1444,$6044,$6144,$6644,$6444,$4044,$4144,$4644,$4444
W11_S0
AT1_S0
dw $0000,$0f00,$0a00,$0b00,$f000,$ff00,$fa00,$fb00,$a000,$af00,$aa00,$ab00,$b000,$bf00,$ba00,$bb00
dw $000f,$0f0f,$0a0f,$0b0f,$f00f,$ff0f,$fa0f,$fb0f,$a00f,$af0f,$aa0f,$ab0f,$b00f,$bf0f,$ba0f,$bb0f
dw $000a,$0f0a,$0a0a,$0b0a,$f00a,$ff0a,$fa0a,$fb0a,$a00a,$af0a,$aa0a,$ab0a,$b00a,$bf0a,$ba0a,$bb0a
@ -83,7 +83,7 @@ W11_S0
dw $00bf,$0fbf,$0abf,$0bbf,$f0bf,$ffbf,$fabf,$fbbf,$a0bf,$afbf,$aabf,$abbf,$b0bf,$bfbf,$babf,$bbbf
dw $00ba,$0fba,$0aba,$0bba,$f0ba,$ffba,$faba,$fbba,$a0ba,$afba,$aaba,$abba,$b0ba,$bfba,$baba,$bbba
dw $00bb,$0fbb,$0abb,$0bbb,$f0bb,$ffbb,$fabb,$fbbb,$a0bb,$afbb,$aabb,$abbb,$b0bb,$bfbb,$babb,$bbbb
W11_S1
AT1_S1
dw $0000,$0c00,$0700,$0a00,$c000,$cc00,$c700,$ca00,$7000,$7c00,$7700,$7a00,$a000,$ac00,$a700,$aa00
dw $000c,$0c0c,$070c,$0a0c,$c00c,$cc0c,$c70c,$ca0c,$700c,$7c0c,$770c,$7a0c,$a00c,$ac0c,$a70c,$aa0c
dw $0007,$0c07,$0707,$0a07,$c007,$cc07,$c707,$ca07,$7007,$7c07,$7707,$7a07,$a007,$ac07,$a707,$aa07
@ -100,7 +100,7 @@ W11_S1
dw $00ac,$0cac,$07ac,$0aac,$c0ac,$ccac,$c7ac,$caac,$70ac,$7cac,$77ac,$7aac,$a0ac,$acac,$a7ac,$aaac
dw $00a7,$0ca7,$07a7,$0aa7,$c0a7,$cca7,$c7a7,$caa7,$70a7,$7ca7,$77a7,$7aa7,$a0a7,$aca7,$a7a7,$aaa7
dw $00aa,$0caa,$07aa,$0aaa,$c0aa,$ccaa,$c7aa,$caaa,$70aa,$7caa,$77aa,$7aaa,$a0aa,$acaa,$a7aa,$aaaa
W11_S2
AT1_S2
dw $0000,$0900,$0700,$0a00,$9000,$9900,$9700,$9a00,$7000,$7900,$7700,$7a00,$a000,$a900,$a700,$aa00
dw $0009,$0909,$0709,$0a09,$9009,$9909,$9709,$9a09,$7009,$7909,$7709,$7a09,$a009,$a909,$a709,$aa09
dw $0007,$0907,$0707,$0a07,$9007,$9907,$9707,$9a07,$7007,$7907,$7707,$7a07,$a007,$a907,$a707,$aa07
@ -117,7 +117,7 @@ W11_S2
dw $00a9,$09a9,$07a9,$0aa9,$90a9,$99a9,$97a9,$9aa9,$70a9,$79a9,$77a9,$7aa9,$a0a9,$a9a9,$a7a9,$aaa9
dw $00a7,$09a7,$07a7,$0aa7,$90a7,$99a7,$97a7,$9aa7,$70a7,$79a7,$77a7,$7aa7,$a0a7,$a9a7,$a7a7,$aaa7
dw $00aa,$09aa,$07aa,$0aaa,$90aa,$99aa,$97aa,$9aaa,$70aa,$79aa,$77aa,$7aaa,$a0aa,$a9aa,$a7aa,$aaaa
W11_S3
AT1_S3
dw $0000,$0400,$0500,$0600,$4000,$4400,$4500,$4600,$5000,$5400,$5500,$5600,$6000,$6400,$6500,$6600
dw $0004,$0404,$0504,$0604,$4004,$4404,$4504,$4604,$5004,$5404,$5504,$5604,$6004,$6404,$6504,$6604
dw $0005,$0405,$0505,$0605,$4005,$4405,$4505,$4605,$5005,$5405,$5505,$5605,$6005,$6405,$6505,$6605
@ -134,3 +134,139 @@ W11_S3
dw $0064,$0464,$0564,$0664,$4064,$4464,$4564,$4664,$5064,$5464,$5564,$5664,$6064,$6464,$6564,$6664
dw $0065,$0465,$0565,$0665,$4065,$4465,$4565,$4665,$5065,$5465,$5565,$5665,$6065,$6465,$6565,$6665
dw $0066,$0466,$0566,$0666,$4066,$4466,$4566,$4666,$5066,$5466,$5566,$5666,$6066,$6466,$6566,$6666
AT2_T0
dw $0000,$0200,$0300,$0400,$2000,$2200,$2300,$2400,$3000,$3200,$3300,$3400,$4000,$4200,$4300,$4400
dw $0002,$0202,$0302,$0402,$2002,$2202,$2302,$2402,$3002,$3202,$3302,$3402,$4002,$4202,$4302,$4402
dw $0003,$0203,$0303,$0403,$2003,$2203,$2303,$2403,$3003,$3203,$3303,$3403,$4003,$4203,$4303,$4403
dw $0004,$0204,$0304,$0404,$2004,$2204,$2304,$2404,$3004,$3204,$3304,$3404,$4004,$4204,$4304,$4404
dw $0020,$0220,$0320,$0420,$2020,$2220,$2320,$2420,$3020,$3220,$3320,$3420,$4020,$4220,$4320,$4420
dw $0022,$0222,$0322,$0422,$2022,$2222,$2322,$2422,$3022,$3222,$3322,$3422,$4022,$4222,$4322,$4422
dw $0023,$0223,$0323,$0423,$2023,$2223,$2323,$2423,$3023,$3223,$3323,$3423,$4023,$4223,$4323,$4423
dw $0024,$0224,$0324,$0424,$2024,$2224,$2324,$2424,$3024,$3224,$3324,$3424,$4024,$4224,$4324,$4424
dw $0030,$0230,$0330,$0430,$2030,$2230,$2330,$2430,$3030,$3230,$3330,$3430,$4030,$4230,$4330,$4430
dw $0032,$0232,$0332,$0432,$2032,$2232,$2332,$2432,$3032,$3232,$3332,$3432,$4032,$4232,$4332,$4432
dw $0033,$0233,$0333,$0433,$2033,$2233,$2333,$2433,$3033,$3233,$3333,$3433,$4033,$4233,$4333,$4433
dw $0034,$0234,$0334,$0434,$2034,$2234,$2334,$2434,$3034,$3234,$3334,$3434,$4034,$4234,$4334,$4434
dw $0040,$0240,$0340,$0440,$2040,$2240,$2340,$2440,$3040,$3240,$3340,$3440,$4040,$4240,$4340,$4440
dw $0042,$0242,$0342,$0442,$2042,$2242,$2342,$2442,$3042,$3242,$3342,$3442,$4042,$4242,$4342,$4442
dw $0043,$0243,$0343,$0443,$2043,$2243,$2343,$2443,$3043,$3243,$3343,$3443,$4043,$4243,$4343,$4443
dw $0044,$0244,$0344,$0444,$2044,$2244,$2344,$2444,$3044,$3244,$3344,$3444,$4044,$4244,$4344,$4444
AT2_T1
dw $0000,$0500,$0600,$0000,$5000,$5500,$5600,$5000,$6000,$6500,$6600,$6000,$0000,$0500,$0600,$0000
dw $0005,$0505,$0605,$0005,$5005,$5505,$5605,$5005,$6005,$6505,$6605,$6005,$0005,$0505,$0605,$0005
dw $0006,$0506,$0606,$0006,$5006,$5506,$5606,$5006,$6006,$6506,$6606,$6006,$0006,$0506,$0606,$0006
dw $0000,$0500,$0600,$0000,$5000,$5500,$5600,$5000,$6000,$6500,$6600,$6000,$0000,$0500,$0600,$0000
dw $0050,$0550,$0650,$0050,$5050,$5550,$5650,$5050,$6050,$6550,$6650,$6050,$0050,$0550,$0650,$0050
dw $0055,$0555,$0655,$0055,$5055,$5555,$5655,$5055,$6055,$6555,$6655,$6055,$0055,$0555,$0655,$0055
dw $0056,$0556,$0656,$0056,$5056,$5556,$5656,$5056,$6056,$6556,$6656,$6056,$0056,$0556,$0656,$0056
dw $0050,$0550,$0650,$0050,$5050,$5550,$5650,$5050,$6050,$6550,$6650,$6050,$0050,$0550,$0650,$0050
dw $0060,$0560,$0660,$0060,$5060,$5560,$5660,$5060,$6060,$6560,$6660,$6060,$0060,$0560,$0660,$0060
dw $0065,$0565,$0665,$0065,$5065,$5565,$5665,$5065,$6065,$6565,$6665,$6065,$0065,$0565,$0665,$0065
dw $0066,$0566,$0666,$0066,$5066,$5566,$5666,$5066,$6066,$6566,$6666,$6066,$0066,$0566,$0666,$0066
dw $0060,$0560,$0660,$0060,$5060,$5560,$5660,$5060,$6060,$6560,$6660,$6060,$0060,$0560,$0660,$0060
dw $0000,$0500,$0600,$0000,$5000,$5500,$5600,$5000,$6000,$6500,$6600,$6000,$0000,$0500,$0600,$0000
dw $0005,$0505,$0605,$0005,$5005,$5505,$5605,$5005,$6005,$6505,$6605,$6005,$0005,$0505,$0605,$0005
dw $0006,$0506,$0606,$0006,$5006,$5506,$5606,$5006,$6006,$6506,$6606,$6006,$0006,$0506,$0606,$0006
dw $0000,$0500,$0600,$0000,$5000,$5500,$5600,$5000,$6000,$6500,$6600,$6000,$0000,$0500,$0600,$0000
AT2_T2
dw $0000,$0700,$0800,$0600,$7000,$7700,$7800,$7600,$8000,$8700,$8800,$8600,$6000,$6700,$6800,$6600
dw $0007,$0707,$0807,$0607,$7007,$7707,$7807,$7607,$8007,$8707,$8807,$8607,$6007,$6707,$6807,$6607
dw $0008,$0708,$0808,$0608,$7008,$7708,$7808,$7608,$8008,$8708,$8808,$8608,$6008,$6708,$6808,$6608
dw $0006,$0706,$0806,$0606,$7006,$7706,$7806,$7606,$8006,$8706,$8806,$8606,$6006,$6706,$6806,$6606
dw $0070,$0770,$0870,$0670,$7070,$7770,$7870,$7670,$8070,$8770,$8870,$8670,$6070,$6770,$6870,$6670
dw $0077,$0777,$0877,$0677,$7077,$7777,$7877,$7677,$8077,$8777,$8877,$8677,$6077,$6777,$6877,$6677
dw $0078,$0778,$0878,$0678,$7078,$7778,$7878,$7678,$8078,$8778,$8878,$8678,$6078,$6778,$6878,$6678
dw $0076,$0776,$0876,$0676,$7076,$7776,$7876,$7676,$8076,$8776,$8876,$8676,$6076,$6776,$6876,$6676
dw $0080,$0780,$0880,$0680,$7080,$7780,$7880,$7680,$8080,$8780,$8880,$8680,$6080,$6780,$6880,$6680
dw $0087,$0787,$0887,$0687,$7087,$7787,$7887,$7687,$8087,$8787,$8887,$8687,$6087,$6787,$6887,$6687
dw $0088,$0788,$0888,$0688,$7088,$7788,$7888,$7688,$8088,$8788,$8888,$8688,$6088,$6788,$6888,$6688
dw $0086,$0786,$0886,$0686,$7086,$7786,$7886,$7686,$8086,$8786,$8886,$8686,$6086,$6786,$6886,$6686
dw $0060,$0760,$0860,$0660,$7060,$7760,$7860,$7660,$8060,$8760,$8860,$8660,$6060,$6760,$6860,$6660
dw $0067,$0767,$0867,$0667,$7067,$7767,$7867,$7667,$8067,$8767,$8867,$8667,$6067,$6767,$6867,$6667
dw $0068,$0768,$0868,$0668,$7068,$7768,$7868,$7668,$8068,$8768,$8868,$8668,$6068,$6768,$6868,$6668
dw $0066,$0766,$0866,$0666,$7066,$7766,$7866,$7666,$8066,$8766,$8866,$8666,$6066,$6766,$6866,$6666
AT2_T3
dw $0000,$0100,$0900,$0600,$1000,$1100,$1900,$1600,$9000,$9100,$9900,$9600,$6000,$6100,$6900,$6600
dw $0001,$0101,$0901,$0601,$1001,$1101,$1901,$1601,$9001,$9101,$9901,$9601,$6001,$6101,$6901,$6601
dw $0009,$0109,$0909,$0609,$1009,$1109,$1909,$1609,$9009,$9109,$9909,$9609,$6009,$6109,$6909,$6609
dw $0006,$0106,$0906,$0606,$1006,$1106,$1906,$1606,$9006,$9106,$9906,$9606,$6006,$6106,$6906,$6606
dw $0010,$0110,$0910,$0610,$1010,$1110,$1910,$1610,$9010,$9110,$9910,$9610,$6010,$6110,$6910,$6610
dw $0011,$0111,$0911,$0611,$1011,$1111,$1911,$1611,$9011,$9111,$9911,$9611,$6011,$6111,$6911,$6611
dw $0019,$0119,$0919,$0619,$1019,$1119,$1919,$1619,$9019,$9119,$9919,$9619,$6019,$6119,$6919,$6619
dw $0016,$0116,$0916,$0616,$1016,$1116,$1916,$1616,$9016,$9116,$9916,$9616,$6016,$6116,$6916,$6616
dw $0090,$0190,$0990,$0690,$1090,$1190,$1990,$1690,$9090,$9190,$9990,$9690,$6090,$6190,$6990,$6690
dw $0091,$0191,$0991,$0691,$1091,$1191,$1991,$1691,$9091,$9191,$9991,$9691,$6091,$6191,$6991,$6691
dw $0099,$0199,$0999,$0699,$1099,$1199,$1999,$1699,$9099,$9199,$9999,$9699,$6099,$6199,$6999,$6699
dw $0096,$0196,$0996,$0696,$1096,$1196,$1996,$1696,$9096,$9196,$9996,$9696,$6096,$6196,$6996,$6696
dw $0060,$0160,$0960,$0660,$1060,$1160,$1960,$1660,$9060,$9160,$9960,$9660,$6060,$6160,$6960,$6660
dw $0061,$0161,$0961,$0661,$1061,$1161,$1961,$1661,$9061,$9161,$9961,$9661,$6061,$6161,$6961,$6661
dw $0069,$0169,$0969,$0669,$1069,$1169,$1969,$1669,$9069,$9169,$9969,$9669,$6069,$6169,$6969,$6669
dw $0066,$0166,$0966,$0666,$1066,$1166,$1966,$1666,$9066,$9166,$9966,$9666,$6066,$6166,$6966,$6666
AT2_S0
dw $0000,$0f00,$0a00,$0b00,$f000,$ff00,$fa00,$fb00,$a000,$af00,$aa00,$ab00,$b000,$bf00,$ba00,$bb00
dw $000f,$0f0f,$0a0f,$0b0f,$f00f,$ff0f,$fa0f,$fb0f,$a00f,$af0f,$aa0f,$ab0f,$b00f,$bf0f,$ba0f,$bb0f
dw $000a,$0f0a,$0a0a,$0b0a,$f00a,$ff0a,$fa0a,$fb0a,$a00a,$af0a,$aa0a,$ab0a,$b00a,$bf0a,$ba0a,$bb0a
dw $000b,$0f0b,$0a0b,$0b0b,$f00b,$ff0b,$fa0b,$fb0b,$a00b,$af0b,$aa0b,$ab0b,$b00b,$bf0b,$ba0b,$bb0b
dw $00f0,$0ff0,$0af0,$0bf0,$f0f0,$fff0,$faf0,$fbf0,$a0f0,$aff0,$aaf0,$abf0,$b0f0,$bff0,$baf0,$bbf0
dw $00ff,$0fff,$0aff,$0bff,$f0ff,$ffff,$faff,$fbff,$a0ff,$afff,$aaff,$abff,$b0ff,$bfff,$baff,$bbff
dw $00fa,$0ffa,$0afa,$0bfa,$f0fa,$fffa,$fafa,$fbfa,$a0fa,$affa,$aafa,$abfa,$b0fa,$bffa,$bafa,$bbfa
dw $00fb,$0ffb,$0afb,$0bfb,$f0fb,$fffb,$fafb,$fbfb,$a0fb,$affb,$aafb,$abfb,$b0fb,$bffb,$bafb,$bbfb
dw $00a0,$0fa0,$0aa0,$0ba0,$f0a0,$ffa0,$faa0,$fba0,$a0a0,$afa0,$aaa0,$aba0,$b0a0,$bfa0,$baa0,$bba0
dw $00af,$0faf,$0aaf,$0baf,$f0af,$ffaf,$faaf,$fbaf,$a0af,$afaf,$aaaf,$abaf,$b0af,$bfaf,$baaf,$bbaf
dw $00aa,$0faa,$0aaa,$0baa,$f0aa,$ffaa,$faaa,$fbaa,$a0aa,$afaa,$aaaa,$abaa,$b0aa,$bfaa,$baaa,$bbaa
dw $00ab,$0fab,$0aab,$0bab,$f0ab,$ffab,$faab,$fbab,$a0ab,$afab,$aaab,$abab,$b0ab,$bfab,$baab,$bbab
dw $00b0,$0fb0,$0ab0,$0bb0,$f0b0,$ffb0,$fab0,$fbb0,$a0b0,$afb0,$aab0,$abb0,$b0b0,$bfb0,$bab0,$bbb0
dw $00bf,$0fbf,$0abf,$0bbf,$f0bf,$ffbf,$fabf,$fbbf,$a0bf,$afbf,$aabf,$abbf,$b0bf,$bfbf,$babf,$bbbf
dw $00ba,$0fba,$0aba,$0bba,$f0ba,$ffba,$faba,$fbba,$a0ba,$afba,$aaba,$abba,$b0ba,$bfba,$baba,$bbba
dw $00bb,$0fbb,$0abb,$0bbb,$f0bb,$ffbb,$fabb,$fbbb,$a0bb,$afbb,$aabb,$abbb,$b0bb,$bfbb,$babb,$bbbb
AT2_S1
dw $0000,$0600,$0c00,$0900,$6000,$6600,$6c00,$6900,$c000,$c600,$cc00,$c900,$9000,$9600,$9c00,$9900
dw $0006,$0606,$0c06,$0906,$6006,$6606,$6c06,$6906,$c006,$c606,$cc06,$c906,$9006,$9606,$9c06,$9906
dw $000c,$060c,$0c0c,$090c,$600c,$660c,$6c0c,$690c,$c00c,$c60c,$cc0c,$c90c,$900c,$960c,$9c0c,$990c
dw $0009,$0609,$0c09,$0909,$6009,$6609,$6c09,$6909,$c009,$c609,$cc09,$c909,$9009,$9609,$9c09,$9909
dw $0060,$0660,$0c60,$0960,$6060,$6660,$6c60,$6960,$c060,$c660,$cc60,$c960,$9060,$9660,$9c60,$9960
dw $0066,$0666,$0c66,$0966,$6066,$6666,$6c66,$6966,$c066,$c666,$cc66,$c966,$9066,$9666,$9c66,$9966
dw $006c,$066c,$0c6c,$096c,$606c,$666c,$6c6c,$696c,$c06c,$c66c,$cc6c,$c96c,$906c,$966c,$9c6c,$996c
dw $0069,$0669,$0c69,$0969,$6069,$6669,$6c69,$6969,$c069,$c669,$cc69,$c969,$9069,$9669,$9c69,$9969
dw $00c0,$06c0,$0cc0,$09c0,$60c0,$66c0,$6cc0,$69c0,$c0c0,$c6c0,$ccc0,$c9c0,$90c0,$96c0,$9cc0,$99c0
dw $00c6,$06c6,$0cc6,$09c6,$60c6,$66c6,$6cc6,$69c6,$c0c6,$c6c6,$ccc6,$c9c6,$90c6,$96c6,$9cc6,$99c6
dw $00cc,$06cc,$0ccc,$09cc,$60cc,$66cc,$6ccc,$69cc,$c0cc,$c6cc,$cccc,$c9cc,$90cc,$96cc,$9ccc,$99cc
dw $00c9,$06c9,$0cc9,$09c9,$60c9,$66c9,$6cc9,$69c9,$c0c9,$c6c9,$ccc9,$c9c9,$90c9,$96c9,$9cc9,$99c9
dw $0090,$0690,$0c90,$0990,$6090,$6690,$6c90,$6990,$c090,$c690,$cc90,$c990,$9090,$9690,$9c90,$9990
dw $0096,$0696,$0c96,$0996,$6096,$6696,$6c96,$6996,$c096,$c696,$cc96,$c996,$9096,$9696,$9c96,$9996
dw $009c,$069c,$0c9c,$099c,$609c,$669c,$6c9c,$699c,$c09c,$c69c,$cc9c,$c99c,$909c,$969c,$9c9c,$999c
dw $0099,$0699,$0c99,$0999,$6099,$6699,$6c99,$6999,$c099,$c699,$cc99,$c999,$9099,$9699,$9c99,$9999
AT2_S2
dw $0000,$0d00,$0700,$0a00,$d000,$dd00,$d700,$da00,$7000,$7d00,$7700,$7a00,$a000,$ad00,$a700,$aa00
dw $000d,$0d0d,$070d,$0a0d,$d00d,$dd0d,$d70d,$da0d,$700d,$7d0d,$770d,$7a0d,$a00d,$ad0d,$a70d,$aa0d
dw $0007,$0d07,$0707,$0a07,$d007,$dd07,$d707,$da07,$7007,$7d07,$7707,$7a07,$a007,$ad07,$a707,$aa07
dw $000a,$0d0a,$070a,$0a0a,$d00a,$dd0a,$d70a,$da0a,$700a,$7d0a,$770a,$7a0a,$a00a,$ad0a,$a70a,$aa0a
dw $00d0,$0dd0,$07d0,$0ad0,$d0d0,$ddd0,$d7d0,$dad0,$70d0,$7dd0,$77d0,$7ad0,$a0d0,$add0,$a7d0,$aad0
dw $00dd,$0ddd,$07dd,$0add,$d0dd,$dddd,$d7dd,$dadd,$70dd,$7ddd,$77dd,$7add,$a0dd,$addd,$a7dd,$aadd
dw $00d7,$0dd7,$07d7,$0ad7,$d0d7,$ddd7,$d7d7,$dad7,$70d7,$7dd7,$77d7,$7ad7,$a0d7,$add7,$a7d7,$aad7
dw $00da,$0dda,$07da,$0ada,$d0da,$ddda,$d7da,$dada,$70da,$7dda,$77da,$7ada,$a0da,$adda,$a7da,$aada
dw $0070,$0d70,$0770,$0a70,$d070,$dd70,$d770,$da70,$7070,$7d70,$7770,$7a70,$a070,$ad70,$a770,$aa70
dw $007d,$0d7d,$077d,$0a7d,$d07d,$dd7d,$d77d,$da7d,$707d,$7d7d,$777d,$7a7d,$a07d,$ad7d,$a77d,$aa7d
dw $0077,$0d77,$0777,$0a77,$d077,$dd77,$d777,$da77,$7077,$7d77,$7777,$7a77,$a077,$ad77,$a777,$aa77
dw $007a,$0d7a,$077a,$0a7a,$d07a,$dd7a,$d77a,$da7a,$707a,$7d7a,$777a,$7a7a,$a07a,$ad7a,$a77a,$aa7a
dw $00a0,$0da0,$07a0,$0aa0,$d0a0,$dda0,$d7a0,$daa0,$70a0,$7da0,$77a0,$7aa0,$a0a0,$ada0,$a7a0,$aaa0
dw $00ad,$0dad,$07ad,$0aad,$d0ad,$ddad,$d7ad,$daad,$70ad,$7dad,$77ad,$7aad,$a0ad,$adad,$a7ad,$aaad
dw $00a7,$0da7,$07a7,$0aa7,$d0a7,$dda7,$d7a7,$daa7,$70a7,$7da7,$77a7,$7aa7,$a0a7,$ada7,$a7a7,$aaa7
dw $00aa,$0daa,$07aa,$0aaa,$d0aa,$ddaa,$d7aa,$daaa,$70aa,$7daa,$77aa,$7aaa,$a0aa,$adaa,$a7aa,$aaaa
AT2_S3
dw $0000,$0e00,$0500,$0600,$e000,$ee00,$e500,$e600,$5000,$5e00,$5500,$5600,$6000,$6e00,$6500,$6600
dw $000e,$0e0e,$050e,$060e,$e00e,$ee0e,$e50e,$e60e,$500e,$5e0e,$550e,$560e,$600e,$6e0e,$650e,$660e
dw $0005,$0e05,$0505,$0605,$e005,$ee05,$e505,$e605,$5005,$5e05,$5505,$5605,$6005,$6e05,$6505,$6605
dw $0006,$0e06,$0506,$0606,$e006,$ee06,$e506,$e606,$5006,$5e06,$5506,$5606,$6006,$6e06,$6506,$6606
dw $00e0,$0ee0,$05e0,$06e0,$e0e0,$eee0,$e5e0,$e6e0,$50e0,$5ee0,$55e0,$56e0,$60e0,$6ee0,$65e0,$66e0
dw $00ee,$0eee,$05ee,$06ee,$e0ee,$eeee,$e5ee,$e6ee,$50ee,$5eee,$55ee,$56ee,$60ee,$6eee,$65ee,$66ee
dw $00e5,$0ee5,$05e5,$06e5,$e0e5,$eee5,$e5e5,$e6e5,$50e5,$5ee5,$55e5,$56e5,$60e5,$6ee5,$65e5,$66e5
dw $00e6,$0ee6,$05e6,$06e6,$e0e6,$eee6,$e5e6,$e6e6,$50e6,$5ee6,$55e6,$56e6,$60e6,$6ee6,$65e6,$66e6
dw $0050,$0e50,$0550,$0650,$e050,$ee50,$e550,$e650,$5050,$5e50,$5550,$5650,$6050,$6e50,$6550,$6650
dw $005e,$0e5e,$055e,$065e,$e05e,$ee5e,$e55e,$e65e,$505e,$5e5e,$555e,$565e,$605e,$6e5e,$655e,$665e
dw $0055,$0e55,$0555,$0655,$e055,$ee55,$e555,$e655,$5055,$5e55,$5555,$5655,$6055,$6e55,$6555,$6655
dw $0056,$0e56,$0556,$0656,$e056,$ee56,$e556,$e656,$5056,$5e56,$5556,$5656,$6056,$6e56,$6556,$6656
dw $0060,$0e60,$0560,$0660,$e060,$ee60,$e560,$e660,$5060,$5e60,$5560,$5660,$6060,$6e60,$6560,$6660
dw $006e,$0e6e,$056e,$066e,$e06e,$ee6e,$e56e,$e66e,$506e,$5e6e,$556e,$566e,$606e,$6e6e,$656e,$666e
dw $0065,$0e65,$0565,$0665,$e065,$ee65,$e565,$e665,$5065,$5e65,$5565,$5665,$6065,$6e65,$6565,$6665
dw $0066,$0e66,$0566,$0666,$e066,$ee66,$e566,$e666,$5066,$5e66,$5566,$5666,$6066,$6e66,$6566,$6666

View File

@ -81,10 +81,10 @@ nesPalette
; T1: --- $3C $1C $0F
; T2: --- $30 $21 $1C
; T3: --- RRR $17 $1C
; S0: --- $16 $27 $18 --> $37 $27 $16
; S0: --- --- $27 --- --> $37 $27 $16
; S1: --- $1C $36 $17
; S2: --- $16 $30 $27
; S3: --- $1D $3C $1C --> $0F RR $29 $1A $09 $36 $1C $30 $21 $16 $27 $18 $17 $3C $1D $37 : 0 free colors
; S3: --- $1D $3C $1C --> $0F RR $29 $1A $09 $3C $1C $30 $21 $17 $27 $18 $36 $16 $0C $16: 0 free colors
; --> $00 $01 $02 $03 $04 $05 $06 $07 $08 $09 $0A $0B $0C $0D $0E $0F
;
; Mapped palettes

View File

@ -1109,6 +1109,8 @@ USER_TILE_ADDR equ 184 ; address in the tile data bank (set on entr
USER_FREE_SPACE equ 186 ; a few bytes of scratch space
USER_SCREEN_ADDR equ 190
USER_TEMP_0 equ 192
USER_TEMP_1 equ 194
LDA_IND_LONG_IDX equ $B7
ORA_IND_LONG_IDX equ $17
@ -1146,21 +1148,21 @@ drawTileToScreen
adc #$0008 ; Sprite palettes are in the second half
xba
clc
adc #W11_T0
adcl SwizzlePtr
sta USER_FREE_SPACE
lda #^W11_T0
lda #^AT1_T0 ; Bank is a constant
sta USER_FREE_SPACE+2 ; Set the pointer to the right swizzle table
pla
bit #$0040
beq :no_prio
bit #$0100
; jeq :drawPriorityToScreen
jeq :drawPriorityToScreen
; jmp :drawPriorityToScreenV
:no_prio
bit #$0100
; jne :drawTileToScreenV
jne :drawTileToScreenV
]line equ 0
lup 8
@ -1188,8 +1190,176 @@ drawTileToScreen
rts
:drawTileToScreenV
]line equ 0
lup 8
ldx USER_TILE_ADDR
ldy: {]line*4}+2,x ; Load the tile data lookup value
lda: {]line*4}+32+2,x ; Load the mask value
ldx USER_SCREEN_ADDR
andl $010000+{{7-]line}*SHR_LINE_WIDTH}+2,x ; Mask against the screen
db ORA_IND_LONG_IDX,USER_FREE_SPACE ; Insert the actual tile data
stal $010000+{{7-]line}*SHR_LINE_WIDTH}+2,x
ldx USER_TILE_ADDR
ldy: {]line*4},x ; Load the tile data lookup value
lda: {]line*4}+32,x ; Load the mask value
ldx USER_SCREEN_ADDR
andl $010000+{{7-]line}*SHR_LINE_WIDTH},x ; Mask against the screen
db ORA_IND_LONG_IDX,USER_FREE_SPACE ; Insert the actual tile data
stal $010000+{{7-]line}*SHR_LINE_WIDTH},x
]line equ ]line+1
--^
plb
plb ; Restore initial data bank
rts
:drawPriorityToScreen
]line equ 0
lup 8
ldx USER_TILE_ADDR
lda: {]line*4}+32+2,x ; Save the inverted mask
eor #$FFFF
sta USER_TEMP_1
ldy: {]line*4}+2,x ; Load the tile data lookup value
db LDA_IND_LONG_IDX,USER_FREE_SPACE ; Insert the actual tile data
ldx USER_SCREEN_ADDR
eorl $010000+{]line*SHR_LINE_WIDTH}+2,x
sta USER_TEMP_0
; Convert the screen data to a mask. Zero in screen = zero in mask, else $F
ldal $010000+{]line*SHR_LINE_WIDTH}+2,x
bit #$F000
beq *+5
ora #$F000
bit #$0F00
beq *+5
ora #$0F00
bit #$00F0
beq *+5
ora #$00F0
bit #$000F
beq *+5
ora #$000F
eor #$FFFF
and USER_TEMP_0
and USER_TEMP_1
eorl $010000+{]line*SHR_LINE_WIDTH}+2,x
stal $010000+{]line*SHR_LINE_WIDTH}+2,x
ldx USER_TILE_ADDR
lda: {]line*4}+32,x ; Save the inverted mask
eor #$FFFF
sta USER_TEMP_1
ldy: {]line*4},x ; Load the tile data lookup value
db LDA_IND_LONG_IDX,USER_FREE_SPACE ; Insert the actual tile data
ldx USER_SCREEN_ADDR
eorl $010000+{]line*SHR_LINE_WIDTH},x
sta USER_TEMP_0
ldal $010000+{]line*SHR_LINE_WIDTH},x
bit #$F000
beq *+5
ora #$F000
bit #$0F00
beq *+5
ora #$0F00
bit #$00F0
beq *+5
ora #$00F0
bit #$000F
beq *+5
ora #$000F
eor #$FFFF
and USER_TEMP_0
and USER_TEMP_1
eorl $010000+{]line*SHR_LINE_WIDTH},x
stal $010000+{]line*SHR_LINE_WIDTH},x
]line equ ]line+1
--^
plb
plb ; Restore initial data bank
rts
:drawPriorityToScreenV
]line equ 0
lup 8
ldx USER_TILE_ADDR
lda: {]line*4}+32+2,x ; Save the inverted mask
eor #$FFFF
sta USER_TEMP_1
ldy: {]line*4}+2,x ; Load the tile data lookup value
db LDA_IND_LONG_IDX,USER_FREE_SPACE ; Insert the actual tile data
ldx USER_SCREEN_ADDR
eorl $010000+{{7-]line}*SHR_LINE_WIDTH}+2,x
sta USER_TEMP_0
; Convert the screen data to a mask. Zero in screen = zero in mask, else $F
ldal $010000+{{7-]line}*SHR_LINE_WIDTH}+2,x
bit #$F000
beq *+5
ora #$F000
bit #$0F00
beq *+5
ora #$0F00
bit #$00F0
beq *+5
ora #$00F0
bit #$000F
beq *+5
ora #$000F
eor #$FFFF
and USER_TEMP_0
and USER_TEMP_1
eorl $010000+{{7-]line}*SHR_LINE_WIDTH}+2,x
stal $010000+{{7-]line}*SHR_LINE_WIDTH}+2,x
ldx USER_TILE_ADDR
lda: {]line*4}+32,x ; Save the inverted mask
eor #$FFFF
sta USER_TEMP_1
ldy: {]line*4},x ; Load the tile data lookup value
db LDA_IND_LONG_IDX,USER_FREE_SPACE ; Insert the actual tile data
ldx USER_SCREEN_ADDR
eorl $010000+{{7-]line}*SHR_LINE_WIDTH},x
sta USER_TEMP_0
ldal $010000+{{7-]line}*SHR_LINE_WIDTH},x
bit #$F000
beq *+5
ora #$F000
bit #$0F00
beq *+5
ora #$0F00
bit #$00F0
beq *+5
ora #$00F0
bit #$000F
beq *+5
ora #$000F
eor #$FFFF
and USER_TEMP_0
and USER_TEMP_1
eorl $010000+{{7-]line}*SHR_LINE_WIDTH},x
stal $010000+{{7-]line}*SHR_LINE_WIDTH},x
]line equ ]line+1
--^
plb
plb ; Restore initial data bank
rts
@ -1200,9 +1370,9 @@ NESTileBlitter
lda USER_TILE_ID
and #$0600 ; Select the tile palette from the tile id
clc
adc #W11_T0
adcl SwizzlePtr
sta USER_FREE_SPACE
lda #^W11_T0
lda #^AT1_T0
sta USER_FREE_SPACE+2
ldx USER_TILE_ADDR ; Get the address of the tile (base only)