Phase 2: display the title screen (mmap, vic, screen swap)

Replace helloworld.c with main.c. Add memmap_setup/restore (banks out
KERNAL+BASIC+CHAR ROMs so $E000-$FFFF is free for the 8 KB bitmap and
$D000-$DFFF is I/O), show_screen(n) which copies the title .bin to
$E000 and the .attr to $D000 (screen memory in multicolor bitmap mode)
then flips the VIC into BMM=1 MCM=1 CSEL=1 RSEL=1 DEN=1 with bitmap
base CB13=1 and screen base VM13-VM10=4 ($D018 = 0x48), and
input_fire(port) which reads bit 4 of CIA1 $DC00/$DC01.

build.sh default target is now main.c -> whack_hare.prg (still
builds helloworld explicitly via the existing -c flag if needed).

Verified: ./build.sh -e runs the title screen in oscar64's built-in
emulator and exits cleanly. .map shows code at $0880-$09A6 and
embedded title data at $09A7-$2CCF, well within the 38 KB main
region. .prg is 9428 bytes, well under the 202-block LOAD"*",8,1
limit.

Concerns for Phase 3 (score bar): the score bar will overlay the top
8 pixel rows of the bitmap ($E000-$E13F, 320 bytes). show_screen()
will continue to copy the full .bin to $E000; score_render() will be
called immediately after and overwrite the top 320 bytes. This keeps
show_screen() dumb and lets the score bar be re-rendered on state
change without re-copying the whole 8 KB bitmap.
This commit is contained in:
ballz
2026-07-17 01:27:28 +02:00
parent 33d628aa65
commit 4d697ad8f1
8 changed files with 285 additions and 12 deletions
+33
View File
@@ -0,0 +1,33 @@
// main.c — Whack Hare! entry point (Phase 2: display title screen).
//
// Flow:
// 1. memmap_setup() — bank out KERNAL/BASIC/CHAR ROM.
// 2. show_screen(TITLE) — copy the title bitmap into $E000 and
// configure the VIC for multicolor bitmap
// mode.
// 3. Loop: poll joystick port 1 for fire. When pressed, restore
// the C64's default memory config and return from main() (which
// ends the program).
//
// Build: ./build.sh (compile to src/build/whack_hare.prg)
// Run: ./build.sh -e (headless, in oscar64's built-in emulator)
// ./build.sh -v (VICE x64, interactive, needs a display)
#include "memmap.h"
#include "screens.h"
#include "input.h"
int main(void)
{
memmap_setup();
show_screen(SCREEN_TITLE);
// Phase 2: just poll for fire on port 1 (the Hare / right joystick).
// In Phase 4 this becomes a 50 Hz raster IRQ handler that drives the
// full state machine.
while (!input_fire(1))
;
memmap_restore();
return 0;
}