Compare commits
10 Commits
1080656771
...
de8ec5915f
Author | SHA1 | Date |
---|---|---|
Louis Pearson | de8ec5915f | |
Louis Pearson | e478de9875 | |
Louis Pearson | 1c7f5f5918 | |
Louis Pearson | 8471b51a4a | |
Louis Pearson | 2ab08f6447 | |
Louis Pearson | f136045f58 | |
Louis Pearson | 57b27449a4 | |
Louis Pearson | 40c151a86b | |
Louis Pearson | 2ab9a1f3a0 | |
Louis Pearson | 01b231bc03 |
|
@ -0,0 +1,2 @@
|
||||||
|
zig-cache/
|
||||||
|
zig-out/
|
|
@ -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);
|
||||||
|
}
|
|
@ -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 = .{
|
||||||
|
"",
|
||||||
|
},
|
||||||
|
}
|
582
main.asm
582
main.asm
|
@ -7,7 +7,7 @@ SECTION "Header", ROM0[$100]
|
||||||
|
|
||||||
ds $150 - @, 0 ; Make room for the header
|
ds $150 - @, 0 ; Make room for the header
|
||||||
|
|
||||||
SECTION "Init", ROM0
|
SECTION "Main", ROM0
|
||||||
Init:
|
Init:
|
||||||
; Shut down audio circuitry
|
; Shut down audio circuitry
|
||||||
ld a, 0
|
ld a, 0
|
||||||
|
@ -27,42 +27,48 @@ WaitVBlank:
|
||||||
call InitSprObjLib
|
call InitSprObjLib
|
||||||
|
|
||||||
; Reset hardware OAM
|
; Reset hardware OAM
|
||||||
xor a, a
|
ld a, 0
|
||||||
ld b, 160
|
ld b, 160
|
||||||
ld hl, _OAMRAM
|
ld hl, _OAMRAM
|
||||||
.resetOAM
|
.resetOAM
|
||||||
ld [hli], a
|
ld [hli], a
|
||||||
dec b
|
dec b
|
||||||
jr nz, .resetOAM
|
jp nz, .resetOAM
|
||||||
|
|
||||||
; Copy cat sprite
|
; Copy cat sprite
|
||||||
ld de, GfxCat
|
ld de, Sprites
|
||||||
ld hl, $8000
|
ld hl, $8000
|
||||||
ld bc, GfxCat.end - GfxCat
|
ld bc, Sprites.end - Sprites
|
||||||
call Memcopy
|
call Memcopy
|
||||||
|
|
||||||
; Reset positions
|
; Reset positions
|
||||||
ld hl, wSimplePosition
|
ld d, 0
|
||||||
ld a, 8
|
ld hl, wMetaspriteBegin
|
||||||
ld [hl], a
|
ld bc, wMetaspriteEnd - wMetaspriteBegin
|
||||||
|
call Memset
|
||||||
|
|
||||||
ld hl, wMetaspritePosition
|
; Clear player data
|
||||||
ld a, 0
|
ld a, $05
|
||||||
ld [wMetaspritePosition], a
|
ld [wMetaspritePosition.x+1], a
|
||||||
ld a, $80
|
ld [wMetaspritePosition.y+1], a
|
||||||
ld [wMetaspritePosition + 1], a
|
|
||||||
|
|
||||||
; Copy the tile data
|
; Copy the tile data
|
||||||
ld de, Tiles
|
ld de, Tiles
|
||||||
ld hl, $9000
|
ld hl, $9000
|
||||||
ld bc, TilesEnd - Tiles
|
ld bc, Tiles.end - Tiles
|
||||||
call Memcopy
|
call Memcopy
|
||||||
|
|
||||||
; Copy the tilemap
|
; Clear the tilemap
|
||||||
ld de, Tilemap
|
|
||||||
ld hl, $9800
|
ld hl, $9800
|
||||||
ld bc, TilemapEnd - Tilemap
|
ld bc, (32 * 20)
|
||||||
call Memcopy
|
ld d, 0
|
||||||
|
call Memset
|
||||||
|
|
||||||
|
; Clear shadown OAM
|
||||||
|
ld hl, wShadowOAM
|
||||||
|
ld bc, 160
|
||||||
|
ld d, 0
|
||||||
|
call Memset
|
||||||
|
|
||||||
; Turn the LCD on
|
; Turn the LCD on
|
||||||
ld a, LCDCF_ON | LCDCF_BGON | LCDCF_OBJON | LCDCF_OBJ8
|
ld a, LCDCF_ON | LCDCF_BGON | LCDCF_OBJON | LCDCF_OBJ8
|
||||||
|
@ -82,35 +88,326 @@ WaitVBlank:
|
||||||
ldh [rIF], a
|
ldh [rIF], a
|
||||||
; Enable interrupts
|
; Enable interrupts
|
||||||
ei
|
ei
|
||||||
|
jp Main
|
||||||
|
|
||||||
Main:
|
Main::
|
||||||
call ResetShadowOAM
|
call ResetShadowOAM
|
||||||
|
call UpdateJoypadState
|
||||||
ld de, $0100
|
call HandleInput
|
||||||
ld c, 8
|
call HandlePhysics
|
||||||
ld b, 16
|
call HandleRender
|
||||||
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
|
|
||||||
|
|
||||||
halt
|
halt
|
||||||
nop
|
nop
|
||||||
|
|
||||||
jp Main
|
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::
|
Memcopy::
|
||||||
dec bc
|
dec bc
|
||||||
inc b
|
inc b
|
||||||
|
@ -125,6 +422,22 @@ Memcopy::
|
||||||
jr nz, .loop
|
jr nz, .loop
|
||||||
ret
|
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]
|
SECTION "VBlank Interrupt", ROM0[$0040]
|
||||||
VBlankInterrupt:
|
VBlankInterrupt:
|
||||||
|
@ -137,22 +450,13 @@ VBlankInterrupt:
|
||||||
|
|
||||||
SECTION "VBlank Handler", ROM0
|
SECTION "VBlank Handler", ROM0
|
||||||
VBlankHandler:
|
VBlankHandler:
|
||||||
ldh a, [hFrameCounter]
|
|
||||||
|
|
||||||
/*
|
|
||||||
bit 5, a
|
|
||||||
|
|
||||||
ld a, %11100100
|
|
||||||
|
|
||||||
jr z, .skipCpl
|
|
||||||
cpl ; Invert a
|
|
||||||
.skipCpl:
|
|
||||||
ldh [rBGP], a
|
|
||||||
*/
|
|
||||||
|
|
||||||
ld a, HIGH(wShadowOAM)
|
ld a, HIGH(wShadowOAM)
|
||||||
call hOAMDMA
|
call hOAMDMA
|
||||||
|
|
||||||
|
ldh a, [hFrameCounter]
|
||||||
|
inc a
|
||||||
|
ldh [hFrameCounter], a
|
||||||
|
|
||||||
; Reset registers to orignal state
|
; Reset registers to orignal state
|
||||||
pop hl
|
pop hl
|
||||||
pop de
|
pop de
|
||||||
|
@ -164,126 +468,90 @@ SECTION "Frame Counter", HRAM
|
||||||
hFrameCounter:
|
hFrameCounter:
|
||||||
db
|
db
|
||||||
|
|
||||||
|
|
||||||
SECTION "Tile data", ROM0
|
SECTION "Tile data", ROM0
|
||||||
|
|
||||||
Tiles:
|
Tiles:
|
||||||
db $00,$ff, $00,$ff, $00,$ff, $00,$ff, $00,$ff, $00,$ff, $00,$ff, $00,$ff
|
INCBIN "tileset.2bpp"
|
||||||
db $00,$ff, $00,$80, $00,$80, $00,$80, $00,$80, $00,$80, $00,$80, $00,$80
|
.end:
|
||||||
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:
|
|
||||||
|
|
||||||
SECTION "Tilemap", ROM0
|
SECTION "Tilemap", ROM0
|
||||||
|
|
||||||
Tilemap:
|
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
|
INCBIN "tileset.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, $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
|
|
||||||
TilemapEnd:
|
TilemapEnd:
|
||||||
|
|
||||||
|
|
||||||
SECTION "Graphics", ROM0
|
SECTION "Graphics", ROM0
|
||||||
GfxCat:
|
Sprites:
|
||||||
INCBIN "cat.2bpp"
|
INCBIN "sprites.2bpp"
|
||||||
.end::
|
.end::
|
||||||
|
|
||||||
CatMetasprite:
|
ShadowMetasprite:
|
||||||
db 16, 8, 0, 0
|
db 12, 0, 1, 0
|
||||||
db 12, 16, 0, 0
|
db 128
|
||||||
db 20, 20, 0, 0
|
|
||||||
db 24, 12, 0, 0
|
PlayerHead:
|
||||||
db 128
|
.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
|
SECTION "Position Vars", WRAM0
|
||||||
; 8-bit X position
|
wMetaspriteBegin:
|
||||||
wSimplePosition:
|
|
||||||
ds 1
|
|
||||||
|
|
||||||
; Q12.4 fixed-point X posiition
|
; Q12.4 fixed-point X posiition
|
||||||
wMetaspritePosition:
|
wMetaspritePosition::
|
||||||
dw
|
.x:
|
||||||
|
dw
|
||||||
|
.y:
|
||||||
|
dw
|
||||||
|
.z:
|
||||||
|
dw
|
||||||
|
.frame:
|
||||||
|
db
|
||||||
|
.whichHead:
|
||||||
|
db
|
||||||
|
|
||||||
; Q4.4 fixed-point velocity
|
; Q4.4 fixed-point velocity
|
||||||
wMetaspriteVelocity::
|
wMetaspriteVelocity::
|
||||||
db
|
.x:
|
||||||
|
dw
|
||||||
|
.y:
|
||||||
|
dw
|
||||||
|
.z:
|
||||||
|
dw
|
||||||
|
.boost:
|
||||||
|
db
|
||||||
|
.boosting:
|
||||||
|
db
|
||||||
|
wMetaspriteEnd:
|
||||||
|
|
||||||
|
SECTION "Joypad Vars", WRAM0
|
||||||
|
wJoypadState:
|
||||||
|
ds 1
|
||||||
|
wJoypadPressed:
|
||||||
|
ds 1
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 326 B |
Binary file not shown.
After Width: | Height: | Size: 975 B |
Binary file not shown.
After Width: | Height: | Size: 306 B |
Loading…
Reference in New Issue