mirror of
https://github.com/lscharen/iigs-game-engine.git
synced 2025-03-03 01:29:44 +00:00
Initial palette work; fix memory init bug
This commit is contained in:
parent
cb13c2ae2d
commit
25c82cc44b
@ -327,7 +327,6 @@ CopyNametable
|
||||
asl
|
||||
asl
|
||||
|
||||
; lda #$0000+{2*32}
|
||||
sta Tmp2
|
||||
lda #0
|
||||
sta Tmp3
|
||||
@ -414,6 +413,13 @@ triggerNMI
|
||||
native_joy ENT
|
||||
db 0,0
|
||||
|
||||
; X = address in the rom file
|
||||
; A = address to write
|
||||
;
|
||||
; This keeps the tile in 2-bit mode in a format that makes it easy to look up pixel data
|
||||
; based on a dynamic palette selection
|
||||
|
||||
|
||||
; X = address in the rom file
|
||||
; A = address to write
|
||||
|
||||
@ -571,10 +577,16 @@ DLUT dw $00,$01,$10,$11 ; CHR_ROM[0] = xx, CHR_ROM[8] = 00
|
||||
dw $20,$21,$30,$31 ; CHR_ROM[0] = xx, CHR_ROM[8] = 10
|
||||
dw $22,$23,$32,$33 ; CHR_ROM[0] = xx, CHR_ROM[8] = 11
|
||||
|
||||
MLUT dw $FF,$F0,$0F,$00
|
||||
dw $F0,$F0,$00,$00
|
||||
dw $0F,$00,$0F,$00
|
||||
dw $00,$00,$00,$00
|
||||
;MLUT dw $FF,$F0,$0F,$00
|
||||
; dw $F0,$F0,$00,$00
|
||||
; dw $0F,$00,$0F,$00
|
||||
; dw $00,$00,$00,$00
|
||||
|
||||
; Inverted mask for using eor/and/eor rendering
|
||||
MLUT dw $00,$0F,$F0,$FF
|
||||
dw $0F,$0F,$FF,$FF
|
||||
dw $F0,$FF,$F0,$FF
|
||||
dw $FF,$FF,$FF,$FF
|
||||
|
||||
; Extracted tiles
|
||||
TileBuff ds 128
|
||||
|
@ -442,6 +442,7 @@ x_offset equ 16
|
||||
|
||||
drawOAMSprites
|
||||
:tmp equ 238
|
||||
|
||||
phb
|
||||
php
|
||||
|
||||
@ -456,6 +457,10 @@ drawOAMSprites
|
||||
cmp #241
|
||||
bcs :hidden
|
||||
|
||||
lda PPU_OAM+1,x ; $FC is an empty tile, don't draw it
|
||||
cmp #$FC
|
||||
beq :hidden
|
||||
|
||||
lda PPU_OAM,x ; Y-coordinate
|
||||
cmp #200+y_offset-9
|
||||
bcs :hidden
|
||||
@ -486,6 +491,7 @@ drawOAMSprites
|
||||
tay
|
||||
|
||||
lda PPU_OAM+2,x
|
||||
pha
|
||||
bit #$0040 ; horizontal flip
|
||||
bne :hflip
|
||||
|
||||
@ -493,7 +499,7 @@ drawOAMSprites
|
||||
and #$FF00
|
||||
lsr ; multiple by 128
|
||||
tax
|
||||
bra drawTilePatch
|
||||
bra :noflip
|
||||
|
||||
:hflip
|
||||
lda PPU_OAM,x ; Loda the tile index into the high byte (x256)
|
||||
@ -502,10 +508,13 @@ drawOAMSprites
|
||||
adc #64 ; horizontal flip
|
||||
tax
|
||||
|
||||
:noflip
|
||||
pla
|
||||
and #$0080 ; Set the vflip bit
|
||||
|
||||
drawTilePatch
|
||||
jsl $000000 ; Draw the tile on the graphics screen
|
||||
|
||||
:hop
|
||||
sep #$30
|
||||
plx
|
||||
|
||||
|
@ -682,10 +682,22 @@ PPUDATA_WRITE EXT
|
||||
PPUDMA_WRITE EXT
|
||||
|
||||
ROMBase ENT
|
||||
ds $8000-14-50
|
||||
ds $8000-14-50-14
|
||||
|
||||
; Hooks to call back to the GTE harness for PPU memory-mapped accesses
|
||||
mx %11
|
||||
mx %11
|
||||
GteInitMem
|
||||
php
|
||||
rep #$30
|
||||
ldx #$015E
|
||||
GteLoop stz 00,x
|
||||
dex
|
||||
dex
|
||||
bpl GteLoop
|
||||
plp
|
||||
rts
|
||||
|
||||
mx %11
|
||||
PPU_CTRL_W
|
||||
jsl PPUCTRL_WRITE
|
||||
rts
|
||||
@ -2870,8 +2882,11 @@ SkipByte dey
|
||||
cpy #$ff ;do this until all bytes in page have been erased
|
||||
bne InitByteLoop
|
||||
dex ;go onto the next page
|
||||
bpl InitPageLoop ;do this until all pages of memory have been erased
|
||||
rts
|
||||
|
||||
cpx #$02 ;GTE wrapper -- zero page and stack are in a different
|
||||
bcs InitPageLoop ;bank, so we provide a little help here
|
||||
; bpl InitPageLoop ;do this until all pages of memory have been erased
|
||||
jmp GteInitMem
|
||||
|
||||
;-------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -137,11 +137,59 @@ RTL_OPCODE equ $6B
|
||||
lda :rtnval ; Address in the compile memory
|
||||
rts
|
||||
|
||||
; 4 palettes for the sprite data. Converts 4 pixels at a time from 0000 0000w wxxy yzz0 -> gggg hhhh iiii jjjj
|
||||
; each swizzle table is 512 bytes long, 2048 bytes for all four. They need to be prec
|
||||
swizzle
|
||||
; Draw a tile directly to the graphics screen as a sprite
|
||||
;
|
||||
; Y = screen address
|
||||
; X = tile address
|
||||
; A = $0001 = ignore mask
|
||||
; = $0080 = vflip
|
||||
; = $0600 = palette select
|
||||
* _DrawSwizzleTileToScreen
|
||||
* :palette equ 240
|
||||
* ; Tile data must be 0000 000w wxxy yzz0
|
||||
* ; Tile mask is normal pixel data
|
||||
|
||||
* and #$0600
|
||||
* sta :palette ; cache the palette bits
|
||||
|
||||
* lda #^swizzle
|
||||
* sta tmp+2
|
||||
|
||||
* ldal tiledata+{]line*4},x
|
||||
* ora :palette
|
||||
* sta tmp
|
||||
* lda: {]line*SHR_LINE_WIDTH},y
|
||||
* andl tiledata+{]line*4}+32,x
|
||||
* ora [tmp]
|
||||
* sta: {]line*SHR_LINE_WIDTH},y
|
||||
|
||||
* tay
|
||||
* lda swizzle,y
|
||||
|
||||
|
||||
* phb
|
||||
* pea $0101
|
||||
* plb
|
||||
* plb
|
||||
|
||||
|
||||
* ]line equ 0
|
||||
* lup 8
|
||||
* lda: {]line*SHR_LINE_WIDTH}+2,y
|
||||
* andl tiledata+{]line*4}+32+2,x
|
||||
* oral tiledata+{]line*4}+2,x
|
||||
* sta: {]line*SHR_LINE_WIDTH}+2,y
|
||||
* lda: {]line*SHR_LINE_WIDTH},y
|
||||
* andl tiledata+{]line*4}+32,x
|
||||
* oral tiledata+{]line*4},x
|
||||
* sta: {]line*SHR_LINE_WIDTH},y
|
||||
* ]line equ ]line+1
|
||||
* --^
|
||||
* plb
|
||||
* rtl ; special exit
|
||||
|
||||
_DrawTileToScreen
|
||||
phb
|
||||
@ -149,15 +197,44 @@ _DrawTileToScreen
|
||||
plb
|
||||
plb
|
||||
|
||||
bit #$0080
|
||||
jne _DrawTileToScreenV
|
||||
|
||||
]line equ 0
|
||||
lup 8
|
||||
lda: {]line*SHR_LINE_WIDTH}+2,y
|
||||
eorl tiledata+{]line*4}+2,x
|
||||
eor #$8888
|
||||
andl tiledata+{]line*4}+32+2,x
|
||||
oral tiledata+{]line*4}+2,x
|
||||
eor: {]line*SHR_LINE_WIDTH}+2,y
|
||||
sta: {]line*SHR_LINE_WIDTH}+2,y
|
||||
|
||||
lda: {]line*SHR_LINE_WIDTH},y
|
||||
eorl tiledata+{]line*4},x
|
||||
eor #$8888
|
||||
andl tiledata+{]line*4}+32,x
|
||||
oral tiledata+{]line*4},x
|
||||
eor: {]line*SHR_LINE_WIDTH},y
|
||||
sta: {]line*SHR_LINE_WIDTH},y
|
||||
]line equ ]line+1
|
||||
--^
|
||||
plb
|
||||
rtl ; special exit
|
||||
|
||||
_DrawTileToScreenV
|
||||
]line equ 0
|
||||
lup 8
|
||||
lda: {]line*SHR_LINE_WIDTH}+2,y
|
||||
eorl tiledata+{{7-]line}*4}+2,x
|
||||
eor #$8888
|
||||
andl tiledata+{{7-]line}*4}+32+2,x
|
||||
eor: {]line*SHR_LINE_WIDTH}+2,y
|
||||
sta: {]line*SHR_LINE_WIDTH}+2,y
|
||||
|
||||
lda: {]line*SHR_LINE_WIDTH},y
|
||||
eorl tiledata+{{7-]line}*4},x
|
||||
eor #$8888
|
||||
andl tiledata+{{7-]line}*4}+32,x
|
||||
eor: {]line*SHR_LINE_WIDTH},y
|
||||
sta: {]line*SHR_LINE_WIDTH},y
|
||||
]line equ ]line+1
|
||||
--^
|
||||
|
@ -229,7 +229,7 @@ _ApplyBG0XPos
|
||||
|
||||
; Alternate entry point if the virt_line_x2 and lines_left_x2 and XMod164 values are passed in externally
|
||||
|
||||
_RestoreBG0OpcodesAlt
|
||||
_ApplyBG0XPosAlt
|
||||
:stk_save equ tmp0
|
||||
:virt_line_x2 equ tmp1
|
||||
:lines_left_x2 equ tmp2
|
||||
|
Loading…
x
Reference in New Issue
Block a user