charset organization improved + doc
This commit is contained in:
parent
c33178ceac
commit
fcdea3cc08
13
README.md
13
README.md
@ -12,8 +12,8 @@ You can also make it output useful extra info with:
|
||||
$ make debug
|
||||
```
|
||||
|
||||
|
||||
## Memory map
|
||||
## Developer docs
|
||||
### Memory map
|
||||
Address | PRG | Description
|
||||
----------------------|-------|------------
|
||||
```$0000 - $0001``` | no | hardware
|
||||
@ -30,3 +30,12 @@ Address | PRG | Description
|
||||
```$D000 - $DFFF``` | no | I/O
|
||||
```$E000 - $FFFF``` | no | Kernal
|
||||
|
||||
### Custom charset
|
||||
Index | Description
|
||||
----------------|-------------
|
||||
```$00 - $1F``` | A-Z (space first)
|
||||
```$20 - $3F``` | A-Z, reversed (space first)
|
||||
```$40 - $4F``` | hex digits
|
||||
```$50 - $5F``` | hex digits, reversed
|
||||
```$60 - ``` | game tiles
|
||||
|
||||
|
@ -7,10 +7,10 @@ x x
|
||||
x x
|
||||
x x
|
||||
x x
|
||||
x x
|
||||
x x
|
||||
x x
|
||||
x x
|
||||
........................................
|
||||
........................................
|
||||
........................................
|
||||
........................................
|
||||
x x
|
||||
x x
|
||||
x x
|
||||
|
@ -252,7 +252,7 @@ foodOK:
|
||||
ldy #0
|
||||
jsr calcTileMem ; calc food address in memory
|
||||
lda (tileMem),y ; check if memory is empty
|
||||
cmp #$20 ; is there a space?
|
||||
cmp #$00 ; is there a space?
|
||||
bne genFood ; if not, must generate another number
|
||||
lda #FOOD_TILE ; else, just put that fucking piece of food there
|
||||
sta (tileMem),y
|
||||
@ -312,7 +312,7 @@ checkEndWallHit:
|
||||
lda listY,x
|
||||
sta calcTileY
|
||||
jsr calcTileMem
|
||||
lda #$20 ; just put a space to erase snake tail tile
|
||||
lda #$00 ; just put a space to erase snake tail tile
|
||||
sta (tileMem),y
|
||||
|
||||
; lda #WALL_COLOR
|
||||
|
@ -4,10 +4,10 @@ gamereset:
|
||||
; Turn MultiColor mode on
|
||||
jsr multicolorOn
|
||||
|
||||
; Upper bar -- fill with reversed spaces, color yellow
|
||||
; Upper bar -- fill with spaces, color yellow
|
||||
ldx #39
|
||||
upperbarLoop:
|
||||
lda #$a0 ; reversed color space
|
||||
lda #$0
|
||||
sta $400,x
|
||||
lda #7
|
||||
sta $d800,x
|
||||
|
@ -32,13 +32,13 @@ ST_PAUSE = 255
|
||||
SCREEN_W = 40
|
||||
SCREEN_H = 24
|
||||
; Snake features
|
||||
SNAKE_TILE = 81
|
||||
SNAKE_TILE = $60
|
||||
SNAKE_COLOR = 13
|
||||
; Food features
|
||||
FOOD_TILE = 90
|
||||
FOOD_TILE = $61
|
||||
FOOD_COLOR = 10
|
||||
; Wall features
|
||||
WALL_TILE = 91
|
||||
WALL_TILE = $62
|
||||
|
||||
; Strings
|
||||
; ----------------------------------------------------------------------
|
||||
|
@ -5,7 +5,7 @@ introreset:
|
||||
|
||||
; Clear screen
|
||||
ldx #$ff
|
||||
lda #$20
|
||||
lda #$00
|
||||
introresetCLS:
|
||||
sta $400,x
|
||||
sta $500,x
|
||||
|
@ -58,33 +58,16 @@ printByte:
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
jsr printDigit
|
||||
ora #$40 ; add 64 (see font)
|
||||
sta $400,y ; print msb char
|
||||
|
||||
txa ; Take least significant nibble (use previous copy)
|
||||
and #$0f
|
||||
jsr printDigit
|
||||
ora #$40 ; add 64 (see font)
|
||||
sta $401,y ; print lsb char
|
||||
|
||||
rts
|
||||
|
||||
; Transform a base-36 digit into a Commodore screen code
|
||||
; Leave input digit in accumulator; returns output screen code in accumulator
|
||||
printDigit:
|
||||
cmp #10
|
||||
bcs printDigitL ; if it is not a decimal digit, then go to printDigitL
|
||||
clc ; it is a decimal digit! Just add `0` (48)
|
||||
adc #48
|
||||
ora #$80 ; reverse color
|
||||
rts
|
||||
printDigitL: ; it is not a decimal digit, then...
|
||||
sec
|
||||
sbc #10 ; take away 10
|
||||
clc
|
||||
adc #1 ; add 1, so you obtain something in [A-F]
|
||||
ora #$80 ; reverse color
|
||||
rts
|
||||
|
||||
; Print null-terminated string on status bar
|
||||
; address of string is given in input using memory location printStatusString
|
||||
printStatus:
|
||||
@ -94,11 +77,10 @@ printStatusLoop:
|
||||
beq printStatusEnd
|
||||
cmp #$20
|
||||
bne printStatusSkipSpace
|
||||
lda #$60
|
||||
lda #$40 ; space + $40
|
||||
printStatusSkipSpace:
|
||||
sec
|
||||
sbc #$40 ; convert from standard ASCII to Commodore screen code
|
||||
ora #$80 ; reverse color
|
||||
sta $413,y
|
||||
iny
|
||||
jmp printStatusLoop
|
||||
@ -114,6 +96,11 @@ printIntro:
|
||||
printIntroLoop:
|
||||
lda (printIntroString),y ; get char from string
|
||||
beq printIntroEnd ; if zero, then end (string must be null-terminated)
|
||||
cmp #$20 ; is space?
|
||||
bne printIntroCheckPunct
|
||||
lda #$0
|
||||
jmp printIntroEndCheck
|
||||
printIntroCheckPunct:
|
||||
cmp #$40 ; is char greater or equal to #$40 = #64 = `@' ?
|
||||
bcc printIntroEndCheck ; if not, it is less, thus it must be
|
||||
; a full stop, comma, colon or something
|
||||
@ -122,6 +109,7 @@ printIntroLoop:
|
||||
; otherwise, it is greater than `@`, so must
|
||||
; subtract 64 because CBM and its encodings
|
||||
; are simply a big shit
|
||||
; TODO -- actually must be fixed with new charset
|
||||
sec
|
||||
sbc #$40
|
||||
|
||||
|
1944
src/tggs.asm
1944
src/tggs.asm
File diff suppressed because it is too large
Load Diff
@ -7,11 +7,11 @@ void flush(char last, int count) {
|
||||
char tile, color;
|
||||
switch(last) {
|
||||
case 'x':
|
||||
tile = (char)91; color = (char)0x8; break;
|
||||
tile = (char)0x62; color = (char)0x8; break;
|
||||
case 'f':
|
||||
tile = (char)90; color = (char)0xa; break;
|
||||
tile = (char)0x61; color = (char)0xa; break;
|
||||
default:
|
||||
tile = (char)32; break;
|
||||
tile = (char)0x00; break;
|
||||
}
|
||||
cout << tile << color << (char)count;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user