Compare commits

..

10 Commits

Author SHA1 Message Date
Louis Pearson de8ec5915f feat: change head facing direction on input
Corrects the input handling code to actually skip when the button is not
pressed
2024-04-20 15:33:59 -06:00
Louis Pearson e478de9875 feat: add animation 2024-04-20 12:08:07 -06:00
Louis Pearson 1c7f5f5918 fix: center player on start 2024-04-19 19:17:53 -06:00
Louis Pearson 8471b51a4a feat: add Memset, clear memory at init 2024-04-19 19:00:23 -06:00
Louis Pearson 2ab08f6447 feat: generate tile data using rgbgfx
Updates to rgbasm 0.7.0
2024-04-19 17:53:22 -06:00
Louis Pearson f136045f58 feat: add boost, fix: make velocity work 2024-04-19 15:05:59 -06:00
Louis Pearson 57b27449a4 feat: gravity kind of works 2024-04-19 14:03:13 -06:00
Louis Pearson 40c151a86b feat: render "shadow" 2024-04-19 09:07:20 -06:00
Louis Pearson 2ab9a1f3a0 feat: 3d movement
Needs gravity, shadow
2024-04-18 01:48:36 -06:00
Louis Pearson 01b231bc03 feat: automate build with zig 2024-04-17 11:22:06 -06:00
8 changed files with 499 additions and 160 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
zig-cache/
zig-out/

57
build.zig Normal file
View File

@ -0,0 +1,57 @@
const std = @import("std");
pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const rgbds = b.dependency("rgbds", .{
.target = target,
.optimize = optimize,
});
const convert_tiles = b.addRunArtifact(rgbds.artifact("rgbgfx"));
convert_tiles.addArg("-u");
convert_tiles.addFileArg(.{ .path = "tilemap.png" });
convert_tiles.addArg("-o");
const tileset_bin = convert_tiles.addOutputFileArg("tileset.2bpp");
convert_tiles.addArg("-t");
const tileset_map = convert_tiles.addOutputFileArg("tileset.tilemap");
const convert_sprites = b.addRunArtifact(rgbds.artifact("rgbgfx"));
convert_sprites.addArg("-u");
convert_sprites.addFileArg(.{ .path = "sprites.png" });
convert_sprites.addArg("-o");
const sprites_bin = convert_sprites.addOutputFileArg("sprites.2bpp");
const assemble = b.addRunArtifact(rgbds.artifact("rgbasm"));
assemble.addArg("-L");
assemble.addArg("-o");
const main_obj = assemble.addOutputFileArg("main.o");
assemble.addFileArg(.{ .path = "main.asm" });
assemble.addArg("--include");
assemble.addDirectoryArg(tileset_bin.dirname());
assemble.addArg("--include");
assemble.addDirectoryArg(tileset_map.dirname());
assemble.addArg("--include");
assemble.addDirectoryArg(sprites_bin.dirname());
const link = b.addRunArtifact(rgbds.artifact("rgblink"));
link.addArg("-o");
const rom = link.addOutputFileArg("3dp.gb");
link.addFileArg(main_obj);
const fix = b.addRunArtifact(rgbds.artifact("rgbfix"));
fix.addArg("-v");
fix.addArg("-p");
fix.addArg("0xFF");
fix.addFileArg(rom);
const install_file = b.addInstallFile(rom, "3dp.gb");
install_file.step.dependOn(&fix.step);
const install = b.getInstallStep();
install.dependOn(&install_file.step);
}

13
build.zig.zon Normal file
View File

@ -0,0 +1,13 @@
.{
.name = "gb3dplatformer",
.version = "0.0.0",
.dependencies = .{
.rgbds = .{
.url = "https://github.com/desttinghim/rgbds/archive/544aa4c532502f6d093670c4d71513a41bd7008b.tar.gz",
.hash = "122064f45d9be6a65a8ae36e92789b33443143eedaa8169bfc07372a8e409c67f17e",
},
},
.paths = .{
"",
},
}

View File

@ -1 +0,0 @@
<EFBFBD>叺・<EFBFBD>⊥・fZ<<

576
main.asm
View File

@ -7,7 +7,7 @@ SECTION "Header", ROM0[$100]
ds $150 - @, 0 ; Make room for the header
SECTION "Init", ROM0
SECTION "Main", ROM0
Init:
; Shut down audio circuitry
ld a, 0
@ -27,42 +27,48 @@ WaitVBlank:
call InitSprObjLib
; Reset hardware OAM
xor a, a
ld a, 0
ld b, 160
ld hl, _OAMRAM
.resetOAM
ld [hli], a
dec b
jr nz, .resetOAM
jp nz, .resetOAM
; Copy cat sprite
ld de, GfxCat
ld de, Sprites
ld hl, $8000
ld bc, GfxCat.end - GfxCat
ld bc, Sprites.end - Sprites
call Memcopy
; Reset positions
ld hl, wSimplePosition
ld a, 8
ld [hl], a
ld d, 0
ld hl, wMetaspriteBegin
ld bc, wMetaspriteEnd - wMetaspriteBegin
call Memset
ld hl, wMetaspritePosition
ld a, 0
ld [wMetaspritePosition], a
ld a, $80
ld [wMetaspritePosition + 1], a
; Clear player data
ld a, $05
ld [wMetaspritePosition.x+1], a
ld [wMetaspritePosition.y+1], a
; Copy the tile data
ld de, Tiles
ld hl, $9000
ld bc, TilesEnd - Tiles
ld bc, Tiles.end - Tiles
call Memcopy
; Copy the tilemap
ld de, Tilemap
; Clear the tilemap
ld hl, $9800
ld bc, TilemapEnd - Tilemap
call Memcopy
ld bc, (32 * 20)
ld d, 0
call Memset
; Clear shadown OAM
ld hl, wShadowOAM
ld bc, 160
ld d, 0
call Memset
; Turn the LCD on
ld a, LCDCF_ON | LCDCF_BGON | LCDCF_OBJON | LCDCF_OBJ8
@ -82,35 +88,326 @@ WaitVBlank:
ldh [rIF], a
; Enable interrupts
ei
jp Main
Main:
Main::
call ResetShadowOAM
ld de, $0100
ld c, 8
ld b, 16
call RenderSimpleSprite
ld hl, wSimplePosition
inc [hl]
ld bc, (96.0 >> 12) & $FFFF
ld a, [wMetaspritePosition]
ld e, a
ld a, [wMetaspritePosition + 1]
ld d, a
ld hl, CatMetasprite
call RenderMetasprite
ldh a, [hFrameCounter]
inc a
ldh [hFrameCounter], a
call UpdateJoypadState
call HandleInput
call HandlePhysics
call HandleRender
halt
nop
jp Main
HandleInput::
ld a, [wJoypadState]
bit PADB_LEFT, a
jr z, .leftend
ld a, PlayerHead.left - PlayerHead
ld [wMetaspritePosition.whichHead], a
ld a, [wMetaspritePosition.x]
sub a, 16
ld b, a
ld [wMetaspritePosition.x], a
ld a, [wMetaspritePosition.x+1]
sbc 0
ld c, a
ld [wMetaspritePosition.x+1], a
.leftend:
ld a, [wJoypadState]
bit PADB_RIGHT, a
jr z, .rightend
ld a, PlayerHead.right - PlayerHead
ld [wMetaspritePosition.whichHead], a
ld a, [wMetaspritePosition.x]
add a, 16
ld b, a
ld [wMetaspritePosition.x], a
ld a, [wMetaspritePosition.x+1]
adc 0
ld c, a
ld [wMetaspritePosition.x+1], a
.rightend:
ld a, [wJoypadState]
bit PADB_UP, a
jr z, .upend
ld a, PlayerHead.up - PlayerHead
ld [wMetaspritePosition.whichHead], a
ld a, [wMetaspritePosition.y]
sub a, 16
ld b, a
ld [wMetaspritePosition.y], a
ld a, [wMetaspritePosition.y+1]
sbc 0
ld c, a
ld [wMetaspritePosition.y+1], a
.upend:
ld a, [wJoypadState]
bit PADB_DOWN, a
jr z, .downend
ld a, PlayerHead.down - PlayerHead
ld [wMetaspritePosition.whichHead], a
ld a, [wMetaspritePosition.y]
add a, 16
ld b, a
ld [wMetaspritePosition.y], a
ld a, [wMetaspritePosition.y+1]
adc 0
ld c, a
ld [wMetaspritePosition.y+1], a
.downend:
; Skip jump code if not on ground
ld a, [wMetaspritePosition.z]
ld b, a
ld a, [wMetaspritePosition.z + 1]
or a, b
jr nz, .jumpend
; While on ground, set boost
ld a, $8
ld [wMetaspriteVelocity.boost], a
ld a, [wJoypadPressed]
bit PADB_A, a
jr z, .boostclear
ld a, [wMetaspriteVelocity.z]
sub a, $20
ld b, a
ld [wMetaspriteVelocity.z], a
ld a, [wMetaspriteVelocity.z+1]
sbc a, $00
ld c, a
ld [wMetaspriteVelocity.z+1], a
jr .boostend
.jumpend:
ld a, [wJoypadState]
bit PADB_A, a
jr z, .boostclear
ld a, $FF
ld [wMetaspriteVelocity.boosting], a
jr .boostend
.boostclear:
ld a, $00
ld [wMetaspriteVelocity.boosting], a
.boostend:
ret
HandleRender::
; Calculate current frame for player
ld a, [hFrameCounter]
and a, %0000_0111
cp a, 0
jr nz, .skipAnim
ld a, [wMetaspritePosition.frame]
inc a
cp PlayerTorso.framesEnd - PlayerTorso.framesStart
jr nz, .skipAnimReset
ld a, 0
.skipAnimReset
ld [wMetaspritePosition.frame], a
.skipAnim
; load de
ld a, [wMetaspritePosition.x]
ld e, a
ld a, [wMetaspritePosition.x + 1]
ld d, a
; load bc
ld a, [wMetaspritePosition.z]
ld c, a
ld a, [wMetaspritePosition.y]
add a, c
ld c, a
ld a, [wMetaspritePosition.z + 1]
ld b, a
ld a, [wMetaspritePosition.y + 1]
adc a, b
ld b, a
; Add frameOffset
ld hl, PlayerTorso.framesStart
ld a, [wMetaspritePosition.frame]
add a, l
ld l, a
jr nc, .noCarry1
inc h
.noCarry1
ld a, [hl]
ld hl, PlayerTorso
add a, l
ld l, a
jr nc, .noCarry2
inc h
.noCarry2
call RenderMetasprite
; Render player head
; load de
ld a, [wMetaspritePosition.x]
ld e, a
ld a, [wMetaspritePosition.x + 1]
ld d, a
; load bc
ld a, [wMetaspritePosition.z]
ld c, a
ld a, [wMetaspritePosition.y]
add a, c
ld c, a
ld a, [wMetaspritePosition.z + 1]
ld b, a
ld a, [wMetaspritePosition.y + 1]
adc a, b
ld b, a
; load hl
ld hl, PlayerHead
ld a, [wMetaspritePosition.whichHead]
add a, l
ld l, a
jr nc, .noCarry3
inc h
.noCarry3
call RenderMetasprite
; Render the shadow
; load de
ld a, [wMetaspritePosition.x]
ld e, a
ld a, [wMetaspritePosition.x + 1]
ld d, a
; load bc
ld a, [wMetaspritePosition.y]
ld c, a
ld a, [wMetaspritePosition.y + 1]
ld b, a
ld hl, ShadowMetasprite
call RenderMetasprite
ret
HandlePhysics::
; Skip gravity if on ground
ld a, [wMetaspritePosition.z]
ld b, a
ld a, [wMetaspritePosition.z + 1]
or a, b
jr z, .endGravity
; Skip gravity if boosting
ld a, [wMetaspriteVelocity.boosting]
ld b, a
ld a, [wMetaspriteVelocity.boost]
and a, b
cp 0
jr z, .startGravity
ld a, [wMetaspriteVelocity.boost]
dec a
ld [wMetaspriteVelocity.boost], a
jr .endGravity
.startGravity
; Apply gravity
ld a, [wMetaspriteVelocity.z]
add a, $04
ld [wMetaspriteVelocity.z], a
ld a, [wMetaspriteVelocity.z+1]
adc a, $00
ld [wMetaspriteVelocity.z+1], a
.endGravity:
; Calculate new z, place in bc
ld a, [wMetaspriteVelocity.z]
ld c, a
ld a, [wMetaspritePosition.z]
add c
ld c, a
ld a, [wMetaspriteVelocity.z + 1]
ld b, a
ld a, [wMetaspritePosition.z + 1]
adc b
ld b, a
; If z is greater than or equal to 0, pos/vel to 0
jr nz, .endLanding
jr nc, .endLanding
.startLanding
ld a, 0
ld [wMetaspritePosition.z], a
ld [wMetaspritePosition.z+1], a
ld [wMetaspriteVelocity.z], a
ld [wMetaspriteVelocity.z+1], a
ld b, a
ld c, a
.endLanding
; Update z position
ld a, c
ld [wMetaspritePosition.z], a
ld a, b
ld [wMetaspritePosition.z+1], a
ret
SECTION "Joypad Routine", ROM0
UpdateJoypadState::
ld hl, rP1
ld [hl], P1F_GET_BTN
; Read button state twice to ensure we get the proper state
ld a, [hl]
ld a, [hl]
ld [hl], P1F_GET_DPAD
cpl ; Inputs are active low - inv so it makes more sense
and PADF_A | PADF_B | PADF_SELECT | PADF_START
ld c, a ; Store lower 4 button bits in c
; On real hardware, rP1 needs to be read 8 times to ensure proper state is read
ld b, 8
.dpadDebounceLoop:
ld a, [hl]
dec b
jr nz, .dpadDebounceLoop
ld [hl], P1F_GET_NONE ; Disable joypad inputs
swap a ; Swap the nibbles to store dpad in upper 4 bits
cpl ; inv the bits
and PADF_RIGHT | PADF_LEFT | PADF_UP | PADF_DOWN
or c
ld c, a
; Compare with previously stored state
ld hl, wJoypadState
xor [hl]
and c
ld [wJoypadPressed], a
ld a, c
ld [wJoypadState], a
ret
SECTION "Memcopy Routine", ROM0
Memcopy::
dec bc
inc b
@ -125,6 +422,22 @@ Memcopy::
jr nz, .loop
ret
; @param hl - Location
; @param bc - Length
; @param d - Value
SECTION "Memset Routine", ROM0
Memset::
dec bc
inc b
inc c
.loop:
ld a, d
ld [hli], a
dec c
jr nz, .loop
dec b
jr nz, .loop
ret
SECTION "VBlank Interrupt", ROM0[$0040]
VBlankInterrupt:
@ -137,22 +450,13 @@ VBlankInterrupt:
SECTION "VBlank Handler", ROM0
VBlankHandler:
ldh a, [hFrameCounter]
/*
bit 5, a
ld a, %11100100
jr z, .skipCpl
cpl ; Invert a
.skipCpl:
ldh [rBGP], a
*/
ld a, HIGH(wShadowOAM)
call hOAMDMA
ldh a, [hFrameCounter]
inc a
ldh [hFrameCounter], a
; Reset registers to orignal state
pop hl
pop de
@ -164,126 +468,90 @@ SECTION "Frame Counter", HRAM
hFrameCounter:
db
SECTION "Tile data", ROM0
Tiles:
db $00,$ff, $00,$ff, $00,$ff, $00,$ff, $00,$ff, $00,$ff, $00,$ff, $00,$ff
db $00,$ff, $00,$80, $00,$80, $00,$80, $00,$80, $00,$80, $00,$80, $00,$80
db $00,$ff, $00,$7e, $00,$7e, $00,$7e, $00,$7e, $00,$7e, $00,$7e, $00,$7e
db $00,$ff, $00,$01, $00,$01, $00,$01, $00,$01, $00,$01, $00,$01, $00,$01
db $00,$ff, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00
db $00,$ff, $00,$7f, $00,$7f, $00,$7f, $00,$7f, $00,$7f, $00,$7f, $00,$7f
db $00,$ff, $03,$fc, $00,$f8, $00,$f0, $00,$e0, $20,$c0, $00,$c0, $40,$80
db $00,$ff, $c0,$3f, $00,$1f, $00,$0f, $00,$07, $04,$03, $00,$03, $02,$01
db $00,$80, $00,$80, $7f,$80, $00,$80, $00,$80, $7f,$80, $7f,$80, $00,$80
db $00,$7e, $2a,$7e, $d5,$7e, $2a,$7e, $54,$7e, $ff,$00, $ff,$00, $00,$00
db $00,$01, $00,$01, $ff,$01, $00,$01, $01,$01, $fe,$01, $ff,$01, $00,$01
db $00,$80, $80,$80, $7f,$80, $80,$80, $00,$80, $ff,$80, $7f,$80, $80,$80
db $00,$7f, $2a,$7f, $d5,$7f, $2a,$7f, $55,$7f, $ff,$00, $ff,$00, $00,$00
db $00,$ff, $aa,$ff, $55,$ff, $aa,$ff, $55,$ff, $fa,$07, $fd,$07, $02,$07
db $00,$7f, $2a,$7f, $d5,$7f, $2a,$7f, $55,$7f, $aa,$7f, $d5,$7f, $2a,$7f
db $00,$ff, $80,$ff, $00,$ff, $80,$ff, $00,$ff, $80,$ff, $00,$ff, $80,$ff
db $40,$80, $00,$80, $7f,$80, $00,$80, $00,$80, $7f,$80, $7f,$80, $00,$80
db $00,$3c, $02,$7e, $85,$7e, $0a,$7e, $14,$7e, $ab,$7e, $95,$7e, $2a,$7e
db $02,$01, $00,$01, $ff,$01, $00,$01, $01,$01, $fe,$01, $ff,$01, $00,$01
db $00,$ff, $80,$ff, $50,$ff, $a8,$ff, $50,$ff, $a8,$ff, $54,$ff, $a8,$ff
db $7f,$80, $7f,$80, $7f,$80, $7f,$80, $7f,$80, $7f,$80, $7f,$80, $7f,$80
db $ff,$00, $ff,$00, $ff,$00, $ab,$7e, $d5,$7e, $ab,$7e, $d5,$7e, $ab,$7e
db $ff,$01, $fe,$01, $ff,$01, $fe,$01, $ff,$01, $fe,$01, $ff,$01, $fe,$01
db $7f,$80, $ff,$80, $7f,$80, $ff,$80, $7f,$80, $ff,$80, $7f,$80, $ff,$80
db $ff,$00, $ff,$00, $ff,$00, $aa,$7f, $d5,$7f, $aa,$7f, $d5,$7f, $aa,$7f
db $f8,$07, $f8,$07, $f8,$07, $80,$ff, $00,$ff, $aa,$ff, $55,$ff, $aa,$ff
db $7f,$80, $7f,$80, $7f,$80, $7f,$80, $7f,$80, $ff,$80, $7f,$80, $ff,$80
db $d5,$7f, $aa,$7f, $d5,$7f, $aa,$7f, $d5,$7f, $aa,$7f, $d5,$7f, $aa,$7f
db $d5,$7e, $ab,$7e, $d5,$7e, $ab,$7e, $d5,$7e, $ab,$7e, $d5,$7e, $eb,$3c
db $54,$ff, $aa,$ff, $54,$ff, $aa,$ff, $54,$ff, $aa,$ff, $54,$ff, $aa,$ff
db $7f,$80, $7f,$80, $7f,$80, $7f,$80, $7f,$80, $7f,$80, $7f,$80, $00,$ff
db $d5,$7e, $ab,$7e, $d5,$7e, $ab,$7e, $d5,$7e, $ab,$7e, $d5,$7e, $2a,$ff
db $ff,$01, $fe,$01, $ff,$01, $fe,$01, $ff,$01, $fe,$01, $ff,$01, $80,$ff
db $7f,$80, $ff,$80, $7f,$80, $ff,$80, $7f,$80, $ff,$80, $7f,$80, $aa,$ff
db $ff,$00, $ff,$00, $ff,$00, $ff,$00, $ff,$00, $ff,$00, $ff,$00, $2a,$ff
db $ff,$01, $fe,$01, $ff,$01, $fe,$01, $fe,$01, $fe,$01, $fe,$01, $80,$ff
db $7f,$80, $ff,$80, $7f,$80, $7f,$80, $7f,$80, $7f,$80, $7f,$80, $00,$ff
db $fe,$01, $fe,$01, $fe,$01, $fe,$01, $fe,$01, $fe,$01, $fe,$01, $80,$ff
db $3f,$c0, $3f,$c0, $3f,$c0, $1f,$e0, $1f,$e0, $0f,$f0, $03,$fc, $00,$ff
db $fd,$03, $fc,$03, $fd,$03, $f8,$07, $f9,$07, $f0,$0f, $c1,$3f, $82,$ff
db $55,$ff, $2a,$7e, $54,$7e, $2a,$7e, $54,$7e, $2a,$7e, $54,$7e, $00,$7e
db $01,$ff, $00,$01, $01,$01, $00,$01, $01,$01, $00,$01, $01,$01, $00,$01
db $54,$ff, $ae,$f8, $50,$f0, $a0,$e0, $60,$c0, $80,$c0, $40,$80, $40,$80
db $55,$ff, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00
db $55,$ff, $6a,$1f, $05,$0f, $02,$07, $05,$07, $02,$03, $03,$01, $02,$01
db $54,$ff, $80,$80, $00,$80, $80,$80, $00,$80, $80,$80, $00,$80, $00,$80
db $55,$ff, $2a,$1f, $0d,$07, $06,$03, $01,$03, $02,$01, $01,$01, $00,$01
db $55,$ff, $2a,$7f, $55,$7f, $2a,$7f, $55,$7f, $2a,$7f, $55,$7f, $00,$7f
db $55,$ff, $aa,$ff, $55,$ff, $aa,$ff, $55,$ff, $aa,$ff, $55,$ff, $00,$ff
db $15,$ff, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00
db $55,$ff, $6a,$1f, $0d,$07, $06,$03, $01,$03, $02,$01, $03,$01, $00,$01
db $54,$ff, $a8,$ff, $54,$ff, $a8,$ff, $50,$ff, $a0,$ff, $40,$ff, $00,$ff
db $00,$7e, $2a,$7e, $d5,$7e, $2a,$7e, $54,$7e, $ab,$76, $dd,$66, $22,$66
db $00,$7c, $2a,$7e, $d5,$7e, $2a,$7e, $54,$7c, $ff,$00, $ff,$00, $00,$00
db $00,$01, $00,$01, $ff,$01, $02,$01, $07,$01, $fe,$03, $fd,$07, $0a,$0f
db $00,$7c, $2a,$7e, $d5,$7e, $2a,$7e, $54,$7e, $ab,$7e, $d5,$7e, $2a,$7e
db $00,$ff, $a0,$ff, $50,$ff, $a8,$ff, $54,$ff, $a8,$ff, $54,$ff, $aa,$ff
db $dd,$62, $bf,$42, $fd,$42, $bf,$40, $ff,$00, $ff,$00, $f7,$08, $ef,$18
db $ff,$00, $ff,$00, $ff,$00, $ab,$7c, $d5,$7e, $ab,$7e, $d5,$7e, $ab,$7e
db $f9,$07, $fc,$03, $fd,$03, $fe,$01, $ff,$01, $fe,$01, $ff,$01, $fe,$01
db $d5,$7e, $ab,$7e, $d5,$7e, $ab,$7e, $d5,$7e, $ab,$7e, $d5,$7e, $ab,$7c
db $f7,$18, $eb,$1c, $d7,$3c, $eb,$3c, $d5,$3e, $ab,$7e, $d5,$7e, $2a,$ff
db $ff,$01, $fe,$01, $ff,$01, $fe,$01, $ff,$01, $fe,$01, $ff,$01, $a2,$ff
db $7f,$c0, $bf,$c0, $7f,$c0, $bf,$e0, $5f,$e0, $af,$f0, $57,$fc, $aa,$ff
db $ff,$01, $fc,$03, $fd,$03, $fc,$03, $f9,$07, $f0,$0f, $c1,$3f, $82,$ff
db $55,$ff, $2a,$ff, $55,$ff, $2a,$ff, $55,$ff, $2a,$ff, $55,$ff, $00,$ff
db $45,$ff, $a2,$ff, $41,$ff, $82,$ff, $41,$ff, $80,$ff, $01,$ff, $00,$ff
db $54,$ff, $aa,$ff, $54,$ff, $aa,$ff, $54,$ff, $aa,$ff, $54,$ff, $00,$ff
db $15,$ff, $2a,$ff, $15,$ff, $0a,$ff, $15,$ff, $0a,$ff, $01,$ff, $00,$ff
db $01,$ff, $80,$ff, $01,$ff, $80,$ff, $01,$ff, $80,$ff, $01,$ff, $00,$ff
TilesEnd:
INCBIN "tileset.2bpp"
.end:
SECTION "Tilemap", ROM0
Tilemap:
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, 0,0,0,0,0,0,0,0,0,0,0,0
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, 0,0,0,0,0,0,0,0,0,0,0,0
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, 0,0,0,0,0,0,0,0,0,0,0,0
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, 0,0,0,0,0,0,0,0,0,0,0,0
db $00, $00, $01, $02, $03, $01, $04, $03, $01, $05, $00, $01, $05, $00, $06, $04, $07, $00, $00, $00, 0,0,0,0,0,0,0,0,0,0,0,0
db $00, $00, $08, $09, $0a, $0b, $0c, $0d, $0b, $0e, $0f, $08, $0e, $0f, $10, $11, $12, $13, $00, $00, 0,0,0,0,0,0,0,0,0,0,0,0
db $00, $00, $14, $15, $16, $17, $18, $19, $1a, $1b, $0f, $14, $1b, $0f, $14, $1c, $16, $1d, $00, $00, 0,0,0,0,0,0,0,0,0,0,0,0
db $00, $00, $1e, $1f, $20, $21, $22, $23, $24, $22, $25, $1e, $22, $25, $26, $22, $27, $1d, $00, $00, 0,0,0,0,0,0,0,0,0,0,0,0
db $00, $00, $01, $28, $29, $2a, $2b, $2c, $2d, $2b, $2e, $2d, $2f, $30, $2d, $31, $32, $33, $00, $00, 0,0,0,0,0,0,0,0,0,0,0,0
db $00, $00, $08, $34, $0a, $0b, $11, $0a, $0b, $35, $36, $0b, $0e, $0f, $08, $37, $0a, $38, $00, $00, 0,0,0,0,0,0,0,0,0,0,0,0
db $00, $00, $14, $39, $16, $17, $1c, $16, $17, $3a, $3b, $17, $1b, $0f, $14, $3c, $16, $1d, $00, $00, 0,0,0,0,0,0,0,0,0,0,0,0
db $00, $00, $1e, $3d, $3e, $3f, $22, $27, $21, $1f, $20, $21, $22, $25, $1e, $22, $40, $1d, $00, $00, 0,0,0,0,0,0,0,0,0,0,0,0
db $00, $00, $00, $41, $42, $43, $44, $30, $33, $41, $45, $43, $41, $30, $43, $41, $30, $33, $00, $00, 0,0,0,0,0,0,0,0,0,0,0,0
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, 0,0,0,0,0,0,0,0,0,0,0,0
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, 0,0,0,0,0,0,0,0,0,0,0,0
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, 0,0,0,0,0,0,0,0,0,0,0,0
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, 0,0,0,0,0,0,0,0,0,0,0,0
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, 0,0,0,0,0,0,0,0,0,0,0,0
INCBIN "tileset.tilemap"
TilemapEnd:
SECTION "Graphics", ROM0
GfxCat:
INCBIN "cat.2bpp"
Sprites:
INCBIN "sprites.2bpp"
.end::
CatMetasprite:
db 16, 8, 0, 0
db 12, 16, 0, 0
db 20, 20, 0, 0
db 24, 12, 0, 0
ShadowMetasprite:
db 12, 0, 1, 0
db 128
SECTION "Position Vars", WRAM0
; 8-bit X position
wSimplePosition:
ds 1
PlayerHead:
.down:
db 0, 0, 2, 0
db 128
.right:
db 0, 0, 3, 0
db 128
.up:
db 0, 0, 4, 0
db 128
.left:
db 0, 0, 3, OAMF_XFLIP
db 128
PlayerTorso:
.vWalk1:
db 8, 0, 5, 0
db 128
.vWalk2:
db 8, 0, 6, 0
db 128
.vWalk3:
db 8, 0, 6, OAMF_XFLIP
db 128
.framesStart
db .vWalk1 - PlayerTorso
db .vWalk2 - PlayerTorso
db .vWalk1 - PlayerTorso
db .vWalk3 - PlayerTorso
.framesEnd
SECTION "Position Vars", WRAM0
wMetaspriteBegin:
; Q12.4 fixed-point X posiition
wMetaspritePosition:
wMetaspritePosition::
.x:
dw
.y:
dw
.z:
dw
.frame:
db
.whichHead:
db
; Q4.4 fixed-point velocity
wMetaspriteVelocity::
.x:
dw
.y:
dw
.z:
dw
.boost:
db
.boosting:
db
wMetaspriteEnd:
SECTION "Joypad Vars", WRAM0
wJoypadState:
ds 1
wJoypadPressed:
ds 1

BIN
sprites.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 326 B

BIN
tilemap.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 975 B

BIN
tileset.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 306 B