2020-04-01 19:11:08 +00:00
# snake6502
2021-11-07 20:09:27 +00:00
![Intro screenshot ](scrot/intro.png )
2020-04-23 10:26:19 +00:00
![Gameplay screenshot ](scrot/gameplay.png )
2020-04-01 19:11:08 +00:00
*snake6502* is a snake-like game clone for Commodore home computers, written for fun because «I always wanted to code something for a computer of my retrocomputers collection – actually, this is the main reason I collect them: to write programs».
2020-04-23 17:01:05 +00:00
Current development status [here ](https://git.giomba.it/giomba/snake6502 ).
2020-11-21 13:57:53 +00:00
## Download
2021-04-12 20:00:04 +00:00
* [.d64 ](dist/snake6502.d64 ) for floppy disks
* [.bin ](dist/snake6502.bin ) for 8KiB cartridges
2020-11-21 13:57:53 +00:00
2020-04-01 19:11:08 +00:00
## Compile
2020-04-23 10:26:19 +00:00
You need the GNU compiler collection and the [dasm ](https://dasm-assembler.github.io/ ) macro assembler, then:
2020-04-01 19:11:08 +00:00
```
2021-04-12 20:00:04 +00:00
$ git submodule init
$ git submodule update
2020-04-01 19:11:08 +00:00
$ make
```
2020-11-14 18:12:10 +00:00
Interesting targets:
2021-04-12 20:00:04 +00:00
* ```make bin/snake6502.bin``` produces .bin, ready to be burnt on an 8K EEPROM for making a cartridge
* ```make bin/snake6502.d64``` produces .d64, ready to be used for floppy disks
2020-11-14 18:12:10 +00:00
2020-09-15 12:57:10 +00:00
You can also define the following environment variables:
```$ DEBUG=1 make``` build with debugging artifacts
2021-04-12 20:00:04 +00:00
## Tape
Copy ```loader.prg``` and ```packlz``` from disk to tape.
On a physical machine, you can use [disk2tape ](https://git.giomba.it/giomba/cbmutil ).
2020-04-06 16:44:54 +00:00
## Developer docs
2020-10-04 15:48:49 +00:00
### Package
The whole program is assembled into a ```snake.pack``` binary blob with the following structure.
Absolute | Offset | Description
------------|-------------|------------
```$1000``` | ```$0000``` | load address
```$2800``` | ```$1800``` | entry point (start address)
2020-04-06 16:44:54 +00:00
### Memory map
2020-04-01 19:11:08 +00:00
Address | PRG | Description
----------------------|-------|------------
```$0000 - $0001``` | no | hardware
```$0002 - $00FF``` | no | zero page pointers
2020-10-04 15:48:49 +00:00
```$0100 - $01FF``` | no | stack page
2021-11-07 19:58:02 +00:00
```$0200 - $03FF``` | no | operating system variables
```$0400 - $07FF``` | no | video memory
2021-04-12 21:31:21 +00:00
```$1000 - $1FFF``` | yes | SID tune, may overlap charset
```$2000 - $23FF``` | yes | custom char, unused, allow SID overlap
2021-11-07 19:58:02 +00:00
```$2400 - $27FF``` | yes | custom char (actual 0x80+)
2020-10-04 15:48:49 +00:00
```$2800 - $xxxx``` | yes | Program segment (only needed part used)
2020-04-02 14:17:48 +00:00
```$xxxx - $CCFF``` | no | *free ram*
2021-11-07 19:58:02 +00:00
```$CD00 - $CFFF``` | no | data segment (not-initialized vars)
2020-04-01 19:11:08 +00:00
```$D000 - $DFFF``` | no | I/O
```$E000 - $FFFF``` | no | Kernal
2020-10-04 15:48:49 +00:00
### Compression
2021-11-07 19:58:02 +00:00
```snake.pack``` is compressed into ```snake.pack.lz``` using [liblzg ](https://github.com/mbitsnbites/liblzg ), to save space, mainly in order to fit the game in a *PROM.
Decompression occurs with one of the following loaders.
2020-09-15 12:57:10 +00:00
2021-11-07 19:58:02 +00:00
### Loader
#### Cartridge
2020-10-04 15:48:49 +00:00
```cart.asm``` is located at ```$8000``` (standard org address for C64 cartridges), and contains the decompression routine and the ```snake.pack.lz```. It decompresses ```snake.pack.lz``` back to ```$1000```, and jumps to its entry point at ```$2800```.
2021-11-07 19:58:02 +00:00
#### Disk
```loader.asm``` loads at ```$801```, like any other BASIC automatic runner, and contains the decompression routine.
```snake.pack.lz``` is loaded at ```$8000``` from disk drive, then decompressed back to ```$1000```, and finally the loader jumps to the program entry point at ```$2800```.
2020-10-04 15:48:49 +00:00
### Miscellanea
#### Custom charset
2020-04-06 16:44:54 +00:00
Index | Description
----------------|-------------
2021-04-12 21:28:34 +00:00
```$00 - $7F``` | unused (space for SID)
```$80 - $9F``` | A-Z (space first)
```$A0 - $BF``` | A-Z, reversed (space first)
```$C0 - $CF``` | hex digits
```$D0 - $DF``` | hex digits, reversed
2021-11-07 19:58:02 +00:00
```$E0 - $EF``` | game tiles
```$F0 - $FF``` | semigraphic tiles
##### Semigrahic Tiles
Char | Output
----------|--------
```$F0``` | ```◜```
```$F1``` | ```◝```
```$F2``` | ```◟```
```$F3``` | ```◞```
```$F4``` | ```-```
```$F5``` | ```|```
```$F6``` | ```◢```
```$F7``` | ```◣```
```$F8``` | ```◥```
```$F9``` | ```◤```
```$FA``` | ```┴```
```$FB``` | ```┬```
```$FC``` | ```┤```
```$FD``` | ```├```
2020-04-06 16:44:54 +00:00