full screen demo concept

This commit is contained in:
2026-07-13 16:06:51 +02:00
parent 44265afe59
commit e068a41c6d
2 changed files with 252 additions and 95 deletions
+27 -63
View File
@@ -1,6 +1,12 @@
# C64 Demo — `main.asm`
A minimal Commodore 64 demo written in 6502 assembly (compiled with the ACME assembler). The program prints two lines of text on the screen, then enters an infinite loop that cycles the border color.
A Commodore 64 intro written in 6502 assembly (compiled with the ACME assembler). The screen shows:
- giant **TTG** letters in the top half (built from 8×8 bitmaps, drawn with solid block characters),
- **TELETYPE GAMES** centered below,
- a horizontally scrolling credits line (`MR.ZERO - TASNADI ZSOLT / MR.ONE - TARI BALAZS / MR.TWO - TIMAR ZOLTAN / MR.THREE - MEZO BELA`),
- **WWW.TELETYPEGAMES.ORG**,
- **SZEGED, 2026**.
## Build and run
@@ -22,80 +28,38 @@ RUN
### 1. BASIC stub (from `$0801`)
The C64 looks for programs at the start of the BASIC memory area (`$0801`). We place a one-line BASIC program here:
A hand-encoded one-line BASIC program (`10 SYS 2064`) so the user only has to type `RUN`; it jumps to the machine-code entry point at `$0810`.
```
10 SYS 2064
```
### 2. Initialization
This lets the user just type `RUN` — the BASIC interpreter then transfers control to the machine-code entry point at address `2064` ($0810). The `!byte` directives hand-encode the BASIC line: link pointer, line number, `SYS` token (`$9e`), the `" 2064"` ASCII digits, end-of-line zero, and end-of-program marker.
Border and background are set to black, then screen RAM (`$0400`) is filled with spaces and color RAM (`$D800`) with white. Everything is drawn by writing to screen RAM directly — the KERNAL `CHROUT` routine is not used.
### 2. Entry point (`$0810` = 2064)
### 3. Giant letters
```asm
* = $0810
```
Each big letter is an 8×8 bitmap (`bigfont`, one byte per row, MSB = left pixel). The drawing loop walks the three letters, shifts each bitmap row out bit by bit, and writes an inverse-space block (`$A0`) plus yellow into color RAM for every set bit. Letters are 8 columns wide with a 2-column gap, so the 28-column logo is centered starting at column 6, row 2.
Machine code starts here.
### 4. Static texts
### 3. KERNAL and VIC-II addresses
Null-loop copies place the screen-code strings (`!scr`) at fixed, centered screen offsets:
| Symbol | Address| Meaning |
|-----------|--------|----------------------------------|
| `CHROUT` | `$FFD2`| KERNAL character output routine |
| `BORDER` | `$D020`| VIC-II border color register |
| `BG` | `$D021`| VIC-II background color register |
| Text | Row | Color |
|-------------------------|-----|-------------|
| `TELETYPE GAMES` | 12 | white |
| scroller line | 14 | cyan |
| `WWW.TELETYPEGAMES.ORG` | 17 | light green |
| `SZEGED, 2026` | 19 | light grey |
### 4. `start` — initialization
### 5. Scroller (main loop)
- **Background:** light blue (`14`) into `$D021`.
- **Border:** dark blue (`6`) into `$D020`.
- **Clear screen:** PETSCII control code `$93` sent to `CHROUT`.
- **Text color:** white (`$05`).
### 5. `print_loop` — printing the text
Classic null-terminated string output:
```asm
ldx #0
print_loop:
lda message,x ; load character using X as index
beq color_loop ; if 0 → done
jsr CHROUT ; otherwise print it
inx
jmp print_loop
```
At the `message` label there is PETSCII text separated by line breaks (`13`), terminated with a `0` byte.
### 6. `color_loop` — infinite border flashing
```asm
color_loop:
inc BORDER ; border color +1
; two nested delay loops (256*256 iterations)
jmp color_loop
```
`inc $D020` increments the lower 4 bits of the border color on every iteration (the VIC-II only uses those anyway), cycling through all 16 colors. The nested `dex`/`dey` loop is pure busy-wait so the eye can perceive the change — the C64 runs at ~1 MHz, and without the delay the flashing would be invisibly fast.
### 7. `message` — data
```asm
message:
!text "HELLO, COMMODORE 64!"
!byte 13, 13 ; two line breaks
!text "TELETYPE GAMES DEMO"
!byte 13, 0 ; line break + end-of-string
```
The main loop synchronizes to the display by waiting for raster line `$FE` (`$D012`), giving one iteration per frame. Every `SCROLL_SPEED` (4) frames it shifts row 14 one character to the left and feeds the next character of `scrolltext` into the rightmost column; the index wraps at the end of the text, so the credits loop forever.
## Memory map
```
$0801 .. $080F BASIC stub (10 SYS 2064)
$0810 .. ... machine code (start, print_loop, color_loop, message)
$D020 border color (visible while being written)
$D021 background color
$FFD2 KERNAL CHROUT
$0810 .. ... machine code + font bitmaps + texts + variables
$0400 .. $07E7 screen RAM (written directly)
$D800 .. color RAM
$D012 raster line (frame sync)
$D020 / $D021 border / background color
```