Compare commits

..

No commits in common. "d2acd2e7fd9674a9243c17cc1e7827882a9b53c1" and "9f2ddc6621c5e4c7de922701baff3dbd05f56d25" have entirely different histories.

15 changed files with 320 additions and 432 deletions

1
.gitignore vendored
View file

@ -1,3 +1,2 @@
build build
*.swp *.swp
*.swo

View file

@ -11,16 +11,7 @@ ROM_OUTPUT=${BUILD}/${NAME}.gb
OBJECT_OUTPUT=${BUILD}/${NAME}.o OBJECT_OUTPUT=${BUILD}/${NAME}.o
SYMFILE_OUTPUT=${BUILD}/${NAME}.sym SYMFILE_OUTPUT=${BUILD}/${NAME}.sym
LICENSEE="tA"
OLDLIC="0x33"
MBC="0x00"
VERSION="0"
PAD="0xFF"
RAM="0x00"
PP_FLAGS=-f lhg -j -t ${NAME} -k ${LICENSEE} -l ${OLDLIC} -m ${MBC} -n ${VERSION} -p ${PAD} -r ${RAM}
all : ${ENTRY} all : ${ENTRY}
${ASSEMBLER} -o ${OBJECT_OUTPUT} ${ENTRY} \ ${ASSEMBLER} -o ${OBJECT_OUTPUT} ${ENTRY} \
&& ${LINKER} -o ${ROM_OUTPUT} -n ${SYMFILE_OUTPUT} ${OBJECT_OUTPUT} \ && ${LINKER} -o ${ROM_OUTPUT} -n ${SYMFILE_OUTPUT} ${OBJECT_OUTPUT} \
&& ${POSTPROC} -v ${PP_FLAGS} ${ROM_OUTPUT} && ${POSTPROC} -v -p 0 ${ROM_OUTPUT}

View file

@ -2,17 +2,6 @@
just me messing about trying to learn gameboy assembly just me messing about trying to learn gameboy assembly
currently have an animation engine supporting:
* arbitary sized frames
* multiple actors
* multiple animation states per actor (up to 128)
* arbitary number of frames
* arbitary time per frame of animation
* distinct animation timers per actor
* distinct colour palletes per tile in frame (limit 2 as per hardware)
* arbitary position of tiles in the tile bank per actor type
* arbitary positioning of tiles in each frame, including overlapping
== requisites == == requisites ==
built using `rgbds`, will need to be installed for makefile to compile built using `rgbds`, will need to be installed for makefile to compile
@ -22,66 +11,3 @@ built using `rgbds`, will need to be installed for makefile to compile
simply run `make` in the root directory to build the ROM simply run `make` in the root directory to build the ROM
will appear as a `.gb` file in `./build` will appear as a `.gb` file in `./build`
== actor format ==
each actor has the following header:
```
ActorROM::
.structs:
dw ActorIdle
dw VillagerWaving
```
where each pointer under `.structs` is another structure in memory. these pointers may be shared between different actor definitions, however the tilesets for each actor will need to be compatible with the same animation for this to work.
each animation state has the following definition:
```
VillagerWaving::
db 90
db 15
dw .vwFrame01
db 15
dw .vwFrame02
db 15
dw .vwFrame03
db 15
dw .vwFrame04
db 15
dw .vwFrame05
db 15
dw .vwFrame06
```
the first byte contains the total number of frames this animation will run for, and then each following set of 3 bytes contains:
* the number of ticks this animation frame persists for
* a pointer to the frame data
each frame has the following data:
```
.vwFrame01
db (.vwFrame01End - @) / 4
db 8, -16, 17, 0
db 8, -8, 18, 0
db 0, -16, 19, OAMF_PAL1
db 0, -8, 20, OAMF_PAL1
db -8, -16, 21, 0
db -8, -8, 22, 0
.vwFrame01End
```
the first byte is the number of tiles present in this frame of animation (analogous to the number of lines in the frame struct).
each following line is 4 bytes, pertaining to (respectively):
* the x offset of this tile
* the y offset of this tile
* the tile offset
* the attributes byte
the position offsets do not need to take into account the gameboys blanket sprite offsets, and the tile offset is zero indexed, and will be added to another offset based on where this actors tiles lie in memory.
the attribute byte is `xor`ed with the defaults in order to facilitate other pallettes or tile flips.

View file

@ -1,5 +0,0 @@
SECTION "Grass Tile", ROM0
grassTiles::
DB $00,$00,$00,$00,$20,$00,$02,$00
DB $04,$00,$44,$00,$20,$00,$00,$00
grassTilesEnd::

View file

@ -1,32 +0,0 @@
SECTION "VillagerWaving", ROM0
VillagerTiles::
DB $1F,$18,$3F,$20,$7F,$48,$74,$57
DB $26,$25,$0E,$09,$0E,$0A,$1E,$12
DB $F8,$18,$FC,$04,$FE,$12,$2E,$EA
DB $64,$A4,$70,$90,$70,$50,$78,$48
DB $0F,$08,$1F,$12,$1D,$16,$1F,$10
DB $0F,$09,$07,$04,$03,$02,$07,$04
DB $F0,$10,$F8,$48,$B8,$68,$F8,$08
DB $F0,$90,$E0,$20,$C0,$40,$E0,$20
DB $00,$00,$00,$00,$00,$00,$00,$00
DB $01,$01,$03,$02,$03,$02,$07,$04
DB $00,$00,$00,$00,$00,$00,$00,$00
DB $80,$80,$C0,$40,$C0,$40,$E0,$20
DB $0F,$08,$1F,$10,$1F,$12,$1D,$16
DB $0F,$08,$07,$05,$03,$02,$07,$04
DB $F0,$10,$F8,$08,$F8,$48,$B8,$68
DB $F0,$10,$E0,$A0,$C0,$40,$E0,$20
DB $07,$04,$1F,$18,$3F,$20,$7C,$4F
DB $76,$55,$2E,$29,$0E,$0A,$1E,$12
DB $E0,$20,$F8,$18,$FC,$04,$3E,$F2
DB $6E,$AA,$74,$94,$70,$50,$78,$48
DB $0F,$08,$1F,$12,$1D,$16,$1F,$10
DB $0F,$09,$07,$04,$03,$02,$1F,$1C
DB $F0,$10,$F8,$48,$B8,$68,$F8,$08
DB $F0,$90,$E0,$20,$C0,$40,$F8,$38
DB $3F,$20,$7F,$48,$77,$54,$24,$27
DB $06,$05,$0E,$09,$0E,$0A,$1E,$12
DB $FC,$04,$FE,$12,$EE,$2A,$24,$E4
DB $60,$A0,$70,$90,$70,$50,$78,$48
VillagerTilesEnd::

View file

@ -7,7 +7,7 @@ SECTION "Actor", ROM0
ActorROM:: ActorROM::
.structs: .structs:
dw ActorIdle dw ActorIdle
dw VillagerWaving .tiles:
ActorIdle:: ActorIdle::
db 60 db 60
db 15 db 15
@ -49,77 +49,3 @@ ActorIdle::
db 0, -8, 15, 0 db 0, -8, 15, 0
db 0, 0, 16, 0 db 0, 0, 16, 0
.frameVoEnd .frameVoEnd
VillagerWaving::
db 90
db 15
dw .vwFrame01
db 15
dw .vwFrame02
db 15
dw .vwFrame03
db 15
dw .vwFrame04
db 15
dw .vwFrame05
db 15
dw .vwFrame06
.vwFrame01
db (.vwFrame01End - @) / 4
db 8, -16, 17, 0
db 8, -8, 18, 0
db 0, -16, 19, OAMF_PAL1
db 0, -8, 20, OAMF_PAL1
db -8, -16, 21, 0
db -8, -8, 22, 0
.vwFrame01End
.vwFrame02
db (.vwFrame02End - @) / 4
db 8, -16, 17, 0
db 8, -8, 18, 0
db 0, -16, 23, OAMF_PAL1
db 0, -8, 24, OAMF_PAL1
db -8, -16, 21, 0
db -8, -8, 22, 0
.vwFrame02End
.vwFrame03
db (.vwFrame03End - @) / 4
db 8, -16, 25, 0
db 8, -8, 26, 0
db 0, -16, 23, OAMF_PAL1
db 0, -8, 24, OAMF_PAL1
db -8, -16, 21, 0
db -8, -8, 22, 0
.vwFrame03End
.vwFrame04
db (.vwFrame04End - @) / 4
db 8, -16, 17, 0
db 8, -8, 18, 0
db 0, -16, 23, OAMF_PAL1
db 0, -8, 24, OAMF_PAL1
db -8, -16, 21, 0
db -8, -8, 22, 0
.vwFrame04End
.vwFrame05
db (.vwFrame05End - @) / 4
db 8, -16, 17, 0
db 8, -8, 18, 0
db 0, -16, 19, OAMF_PAL1
db 0, -8, 20, OAMF_PAL1
db -8, -16, 21, 0
db -8, -8, 22, 0
.vwFrame05End
.vwFrame06
db (.vwFrame06End - @) / 4
db 8, -16, 29, 0
db 8, -8, 30, 0
db 0, -16, 27, OAMF_PAL1
db 0, -8, 28, OAMF_PAL1
db -8, -16, 21, 0
db -8, -8, 22, 0
.vwFrame06End

View file

@ -7,32 +7,28 @@
bytes 1, XPos bytes 1, XPos
bytes 1, GFXCounter bytes 1, GFXCounter
bytes 1, GFXState bytes 1, GFXState
bytes 1, TileData
words 1, GFXData words 1, GFXData
bytes 1, TileData
end_struct end_struct
SECTION "Actor STructs", WRAM0 SECTION "Actor STructs", WRAM0
dstruct Actor, Player dstruct Actor, Player
dstruct Actor, NPC01
dstruct Actor, NPC02
dstruct Actor, NPC03
dstruct Actor, NPC04
dstruct Actor, NPC05
SECTION "Animation Variables", HRAM SECTION "Animation Variables", WRAM0
hCameraX: dw wCameraX: dw
hCameraY: dw wCameraY: dw
hWorkingX: dw wWorkingX: dw
hWorkingY: dw wWorkingY: dw
hWorkingScreenX: db wWorkingScreenX: db
hWorkingScreenY: db wWorkingScreenY: db
hWorkingState: db wWorkingState: db
hWorkingCounter: db wWorkingCounter: db
hWorkingData: dw wWorkingData: dw
hWorkingTile: db wWorkingTile: db
wWorkingEnd:
SECTION "Animations Subs", ROM0 SECTION "Animations Subs", ROM0
@ -51,105 +47,117 @@ SECTION "Animations Subs", ROM0
RenderActor:: RenderActor::
; @input: hl <- Player ; @input: hl <- Player
; @input: de <- ShadowOAM place ; @input: de <- ShadowOAM place
; clobbers af, bc, de, hl
ld a, [hli] ; a <- YPos ld a, [hli] ; a <- YPos
ldh [hWorkingScreenY], a ld [wWorkingScreenY], a
ld a, [hli] ; a <- XPos ld a, [hli] ; a <- XPos
ldh [hWorkingScreenX], a ld [wWorkingScreenX], a
push hl ; save counter pointer on stack push hl
ld a, [hli] ; a <- GFXCounter ld a, [hli] ; a <- GFXCounter
ldh [hWorkingCounter], a ld [wWorkingCounter], a
ld a, [hli] ; a <- GFXState ld a, [hli] ; a <- GFXState
ldh [hWorkingState], a ld [wWorkingState], a
ld a, [hli] ; a <- TileData
ldh [hWorkingTile], a
ld a, [hli] ; a <- GFXData(Low) ld a, [hli] ; a <- GFXData(Low)
ld h, [hl] ; a <- GFXData (High) ld [wWorkingData+1], a
ld a, [hli] ; a <- GFXData (High)
ld [wWorkingData], a
ld a, [hl] ; a <- TileData
ld [wWorkingTile], a
; fin loading data
ld a, [wWorkingData]
ld l, a ld l, a
ld a, [wWorkingData+1]
ld a, [hWorkingState] ; add actor struct offset saved in wWorkingState ld h, a
; add actor struct offset saved in wWorkingState
ld a, [wWorkingState]
rlca ; double state offset because of word length rlca ; double state offset because of word length
add a, l add a, l
ld l, a ld l, a
adc a, h adc a, h
sub l sub l
ld h, a ; hl contains state struct pointer ld h, a ; hl contains state struct pointer
ld a, [hli]
ld a, [hli] ;
ld h, [hl] ; derefence [hl]
ld l, a ;
ld a, [hWorkingCounter]
inc a
ld b, a ld b, a
ld a, [hl]
ld l, b
ld h, a
ld a, [hli] ; a <- state frame limit ld a, [hli] ; a <- state frame limit
ld b, a
ld a, [wWorkingCounter]
inc a
ld c, a
ld a, b
ld b, c
cp b cp b
ld a, b ld a, b
jr nc, .continueAnimation jr nc, .continueAnimation
xor a xor a
.continueAnimation .continueAnimation
ldh [hWorkingCounter], a ; TODO: make counter 0 indexed so doesnt skip first frame
ld b, h ; ld [wWorkingCounter], a
ld c, l ; save current hl ld b, h
pop hl ; restore counter wram pointer ld c, l
ld [hl], a ; pop hl
ld h, b ; restore hl ld [hl], a
ld l, c ; ld h, b
ld l, c
ld c, a ; save current frame in c .loopFrameFind
xor a ; set a = 0 ld b, a ; b <- current frame count
.loopFrameFind ; ld a, [hli] ; a <- next frame block
ld b, a ; b <- current total ld c, a
ld a, [hli] ; a <- next frame tick limit ld a, b
add b ; add to limit ld b, c
cp c ; compare to limit sub b
jr nc, .foundFrame ; if no carry, cum total > current frame jr z, .foundFrame
jr c, .foundFrame
inc hl inc hl
inc hl inc hl
jr .loopFrameFind jr .loopFrameFind
.foundFrame .foundFrame
ld a, [hli] ld a, [hli]
ld h, [hl] ld b, a
ld l, a ; hl <- pointer to frame data ld a, [hl]
ld h, a
ld l, b ; hl <- pointer to frame data
ld a, [hli] ld a, [hli]
ld b, a ; b <- sprite counter ld b, a ; b <- sprite counter
.spriteLoop .spriteLoop
; load Y position, then offset by -16
ld a, [hli] ; load Y position, then offset by -16 ld a, [hli]
ld c, a ld c, a
ld a, [hWorkingScreenY] ld a, [wWorkingScreenY]
add c add c
ld c, 16 ld c, 16
add c add c
ld [de], a ; store YPos in shadowOAM ld [de], a ; store YPos in shadowOAM
inc de inc de
; load X position, then offset by -8
ld a, [hli] ; load X position, then offset by -8 ld a, [hli]
ld c, a ld c, a
ld a, [hWorkingScreenX] ld a, [wWorkingScreenX]
add c add c
ld c, 8 ld c, 8
add c add c
ld [de], a ; store XPos in shadowOAM ld [de], a ; store YPos in shadowOAM
inc de inc de
; load tile offset, and add to base tile pointer
ld a, [hli] ; load tile offset, and add to base tile pointer ld a, [hli]
ld c, a ld c, a
ld a, [hWorkingTile] ld a, [wWorkingTile]
add c add c
ld [de], a ld [de], a
inc de inc de
; load attributes and xor them
ld a, [hli] ; load attributes and xor them ld a, [hli]
ld c, a ld c, a
ld a, 0 ; TO DO: set base attributes ld a, 0 ; TO DO: set base attributes
xor c xor c
ld [de], a ld [de], a
inc de inc de
; end of single sprite
dec b ; end of single sprite dec b
jr nz, .spriteLoop jr nz, .spriteLoop
ret ret
BUFFER EQU 160
TRUE EQU $42
FALSE EQU $69

View file

@ -12,8 +12,19 @@ P1F_DPAD EQU $20
SECTION "ROM Vars", ROM0 SECTION "ROM Vars", ROM0
dPlayerWidth: db 2
dPlayerHeight: db 2
dPlayerSpriteTiles: db $01, $02, $09, $0A
SECTION "WRAM Vars", WRAM0[$C000] SECTION "WRAM Vars", WRAM0[$C000]
X: dw
N: dw
ANS: db
rPlayerX: db
rPlayerY: db
SECTION "HRAM Vars", HRAM SECTION "HRAM Vars", HRAM
hVBlankFlag: db hVBlankFlag: db

View file

@ -6,9 +6,9 @@ INCLUDE "src/actor.asm"
SECTION "Program Start", ROM0[$150] SECTION "Program Start", ROM0[$150]
Start: Start:
ei
ld a, IEF_VBLANK ld a, IEF_VBLANK
ld [rIE], a ld [rIE], a
ei
xor a xor a
ld [hVBlankFlag], a ld [hVBlankFlag], a
call Wait_VBlank call Wait_VBlank
@ -17,130 +17,40 @@ Start:
call Clear_Map call Clear_Map
call Clear_OAM call Clear_OAM
call Load_Tiles call Load_Tiles
call Load_Map ; call Load_Map
ld a, %11100100 ld a, %11100100
ld [rBGP], a ld [rBGP], a
ld [rOBP0], a ld [rOBP0], a
ld a, %11000100
ld [rOBP1], a
xor a xor a
ld [rSCY], a ld [rSCY], a
ld [rSCX], a ld [rSCX], a
ld [rNR52], a ld [rNR52], a
call CopyDMARoutine
ld a, $3F
ld [Player_YPos], a
ld a, $3A
ld [Player_XPos], a
ld a, $FF
ld [Player_GFXCounter], a
ld a, 1
ld [Player_GFXState], a
xor a
ld [Player_TileData], a
ld a, HIGH(ActorROM)
ld [Player_GFXData+1], a
ld a, LOW(ActorROM)
ld [Player_GFXData], a
ld a, $71
ld [NPC01_YPos], a
ld a, $8C
ld [NPC01_XPos], a
ld a, 20
ld [NPC01_GFXCounter], a
ld a, 1
ld [NPC01_GFXState], a
xor a
ld [NPC01_TileData], a
ld a, HIGH(ActorROM)
ld [NPC01_GFXData+1], a
ld a, LOW(ActorROM)
ld [NPC01_GFXData], a
ld a, $15
ld [NPC02_YPos], a
ld a, $1C
ld [NPC02_XPos], a
ld a, 30
ld [NPC02_GFXCounter], a
ld a, 1
ld [NPC02_GFXState], a
xor a
ld [NPC02_TileData], a
ld a, HIGH(ActorROM)
ld [NPC02_GFXData+1], a
ld a, LOW(ActorROM)
ld [NPC02_GFXData], a
ld a, $29
ld [NPC03_YPos], a
ld a, $90
ld [NPC03_XPos], a
ld a, 40
ld [NPC03_GFXCounter], a
ld a, 1
ld [NPC03_GFXState], a
xor a
ld [NPC03_TileData], a
ld a, HIGH(ActorROM)
ld [NPC03_GFXData+1], a
ld a, LOW(ActorROM)
ld [NPC03_GFXData], a
ld a, $71
ld [NPC04_YPos], a
ld a, $4F
ld [NPC04_XPos], a
ld a, 50
ld [NPC04_GFXCounter], a
ld a, 1
ld [NPC04_GFXState], a
xor a
ld [NPC04_TileData], a
ld a, HIGH(ActorROM)
ld [NPC04_GFXData+1], a
ld a, LOW(ActorROM)
ld [NPC04_GFXData], a
ld a, $4A
ld [NPC05_YPos], a
ld a, $67
ld [NPC05_XPos], a
ld a, $FF
ld [NPC05_GFXCounter], a
ld a, 1
ld [NPC05_GFXState], a
xor a
ld [NPC05_TileData], a
ld a, HIGH(ActorROM)
ld [NPC05_GFXData+1], a
ld a, LOW(ActorROM)
ld [NPC05_GFXData], a
ld a, LCDCF_ON | LCDCF_OBJON | LCDCF_BGON ld a, LCDCF_ON | LCDCF_OBJON | LCDCF_BGON
ld [rLCDC], a ld [rLCDC], a
call CopyDMARoutine
ld a, 72
ld [Player_YPos], a
ld a, 80
ld [Player_XPos], a
xor a
ld [Player_GFXCounter], a
ld [Player_GFXState], a
ld [Player_TileData], a
ld a, HIGH(ActorROM)
ld [Player_GFXData], a
ld a, LOW(ActorROM)
ld [Player_GFXData + 1], a
game_loop: game_loop:
call Hide_OAM call Wait_VBlank
call Read_Pad call Read_Pad
call PC_Update call PC_Update
call Clear_OAM
ld de, wShadowOAM ld de, wShadowOAM
ld hl, Player ld hl, Player
call RenderActor call RenderActor
ld hl, NPC01
call RenderActor
ld hl, NPC02
call RenderActor
ld hl, NPC03
call RenderActor
ld hl, NPC04
call RenderActor
ld hl, NPC05
call RenderActor
call Wait_VBlank
ld a, HIGH(wShadowOAM) ld a, HIGH(wShadowOAM)
call hOAMDMA call hOAMDMA
jr game_loop jr game_loop

View file

@ -2,9 +2,44 @@
; Gameboy Header ; Gameboy Header
;----------------- ;-----------------
SECTION "Entry", ROM0[$100] SECTION "Header", ROM0[$100]
di
; Jump to the "Start" label
; which we must define ourselves
EntryPoint:
nop
jp Start; jp Start;
; Reserve space for header ; ROM Header $104 to $150
ds $150 - @, 0 RomHeader:
; Nintendo Logo $104-$133
db $CE,$ED,$66,$66,$CC,$0D,$00,$0B,$03,$73,$00,$83,$00,$0C,$00,$0D
db $00,$08,$11,$1F,$88,$89,$00,$0E,$DC,$CC,$6E,$E6,$DD,$DD,$D9,$99
db $BB,$BB,$67,$63,$6E,$0E,$EC,$CC,$DD,$DC,$99,$9F,$BB,$B9,$33,$3E
; Title (11 characters) $134-$13E
db "ANIMATION",$00,$00
; Manufacturer Code (4 characters) $13F-$142
db "LATA"
; CGB Flag $143
db $00
; Licensee Code (2 characters) $144-$145
db "00"
; SGB Flag $146
db $00
; Cartridge Type $147
db $00
; ROM Size $148
db $00
; RAM Size $149
db $00
; Destination Code $14A
db $01
; Depreciated Licensee Code $14B
db $33
; Version Number $14C
db $00
; Header Checksum $14D
db $00
; Global Checksum $14E-$14F
db $00, $00

View file

@ -2,8 +2,6 @@ INCLUDE "inc/hardware.inc"
INCLUDE "inc/structs.asm" INCLUDE "inc/structs.asm"
INCLUDE "ass/parecivo.ass" INCLUDE "ass/parecivo.ass"
INCLUDE "ass/tiles.ass" INCLUDE "ass/tiles.ass"
INCLUDE "ass/grass.ass"
INCLUDE "ass/villager.ass"
INCLUDE "ass/map.ass" INCLUDE "ass/map.ass"
INCLUDE "src/animation.asm" INCLUDE "src/animation.asm"
INCLUDE "src/entry.asm" INCLUDE "src/entry.asm"

View file

@ -1,3 +1,102 @@
Player_To_OAM:
; -- first loop --
ld hl, wShadowOAM
ld a, [dPlayerHeight]
ld b, a
ld d, 16
ld a, [rPlayerY]
add d ; d has the base Y value (counting offsets)
ld d, a
.fouter
ld a, [dPlayerWidth]
ld c, a ; c is finner counter
.finner
ld a, d
ld [hl], a
ld a, 4
call .add4hl
; end of finner loop
dec c
jr nz, .finner
ld a, d
ld d, 8
add d
ld d, a
; end of fouter loop
dec b
jr nz, .fouter
; -- second loop --
ld hl, wShadowOAM+1
ld a, [dPlayerHeight]
ld b, a
.souter
ld d, 8
ld a, [rPlayerX]
add d
ld d, a
ld a, [dPlayerWidth]
ld c, a
.sinner
ld a, d
ld [hl], a
add 8
ld d, a
ld a, 4
call .add4hl
dec c
jr nz, .sinner
dec b
jr nz, .souter
; -- third loop --
ld hl, wShadowOAM+2
ld de, dPlayerSpriteTiles
ld a, [dPlayerHeight]
ld b, a
ld a, [dPlayerWidth]
ld c, a
xor a
.tloop1
add b
dec c
jr nz, .tloop1
ld c, a
.tloop2
ld a, [de]
ld [hl], a
ld a, 4
call .add4hl
inc de
dec c
jr nz, .tloop2
; -- fourth loop --
ld hl, wShadowOAM+3
ld a, [dPlayerHeight]
ld b, a
ld a, [dPlayerWidth]
ld c, a
xor a
.lloop1
add b
dec c
jr nz, .lloop1
ld c, a
.lloop2
xor a
ld [hl], a
ld a, 4
call .add4hl
dec c
jr nz, .lloop2
ret
.add4hl:
add a, l ; a = low + old_l
ld l, a ; a = low + old_l = new_l
adc a, h ; a = new_l + old_h + carry
sub l ; a = old_h + carry
ld h, a
ret
PC_Update: PC_Update:
ld b, 0 ld b, 0
ld c, 0 ld c, 0
@ -31,14 +130,6 @@ PC_Update:
ld a, [Player_YPos] ld a, [Player_YPos]
add b add b
ld [Player_YPos], a ld [Player_YPos], a
.a:
ld a, [hNewKeys]
and %00000001 ; a pressed
cp %00000001
jr nz, .end
ld a, [Player_GFXState]
xor %00000001
ld [Player_GFXState], a
.end: .end:
ret ret
@ -55,20 +146,6 @@ Clear_OAM:
jr nz, .loop jr nz, .loop
ret ret
Hide_OAM:
ld hl, wShadowOAM
ld c, (wShadowOAMEnd - wShadowOAM) / 4
.loop:
xor a
ld [hl], a
ld a, l
or 3
inc a
ld l, a
dec c
jr nz, .loop
ret
Clear_Map: Clear_Map:
ld hl, _SCRN0 ld hl, _SCRN0
ld bc, _SCRN0_END - _SCRN0 ld bc, _SCRN0_END - _SCRN0
@ -83,24 +160,20 @@ Clear_Map:
Load_Tiles: Load_Tiles:
ld hl, _BGTILES ld hl, _BGTILES
ld de, grassTiles ld de, parecivo_tile_data
ld bc, grassTilesEnd - grassTiles ld bc, parecivo_tile_data_size
call MemCpy call MemCpy
ld hl, _VRAM ld hl, _VRAM
ld de, parecivo_tile_data ld de, parecivo_tile_data
ld bc, parecivo_tile_data_size ld bc, parecivo_tile_data_size
call MemCpy call MemCpy
ld de, VillagerTiles
ld bc, VillagerTilesEnd - VillagerTiles
call MemCpy
ret ret
Load_Map: Load_Map:
xor a
ld hl, _SCRN0 ld hl, _SCRN0
ld c, 0 ld de, Map
.loop ld bc, Map_Size
ld [hl], a call MemCpy
dec c
jr nz, .loop
ret ret

View file

@ -1,6 +0,0 @@
;----------------
; Text Rendering
;----------------
; Aims
; Get a renderable text to the graphics window,

54
testing/ISSOtm.asm Normal file
View file

@ -0,0 +1,54 @@
PlayerGfx::
INCLUDE "res/actors/player.pal.asm" ; CGB palette
db OAMF_PAL1 ; Additional attr
dw PlayerTiles
PlayerTiles:
; number of tiles:
db (.displayStructs - .tiles) / 16
.tiles
INCBIN "res/actors/player.2bpp"
.displayStructs
dw PlayerStandingUp
dw PlayerWalkingUp
dw PlayerStandingDown
dw PlayerWalkingDown
dw PlayerStandingLeft
dw PlayerWalkingLeft
dw PlayerStandingRight
dw PlayerWalkingRight
PlayerWalkingDown:
db $20
db 8
dw .frame0
db 8
dw .frame1
db 8
dw .frame0
db 8
dw .frame2
.frame0
db (.frame0End - @) / 4
db -31, -8, 0, 0
db -15, -8, 2, 0
db -31, 0, 4, 0
db -15, 0, 6, 0
.frame0End
.frame1
db (.frame1End - @) / 4
db -31, -8, 8, 0
db -15, -8, 10, 0
db -31, 0, 12, 0
db -15, 0, 14, 0
.frame1End
.frame2
db (.frame2End - @) / 4
db -31, -8, 16, 0
db -15, -8, 18, 0
db -31, 0, 20, 0
db -15, 0, 22, 0
.frame2End