saga20101217 - simondotm/stardot-wiki GitHub Wiki
This covers the past few days where I've being doing dribs and drabs when I have had time. First off, some new stuff. I added a pseudo-random number generator as just grabbing a value from &FE44 didn't turn out to be random (interestingly enough Brian Howarth's code just gets the low byte of the system clock for this). I also added the print counter routine, one vital step on getting SCORE working properly.
The other area of work was code reduction, which I saved some notes on byte reductions. The first step was turning JSR xyz:RTS into JMP xyz; this saved about 5 bytes. Next I added a couple of functions to perform 16-bit addition to the most commonly used pointers. Some moving pointers around so I could could use common code also saved some bytes. Finally I found a whole chunk of code that I had duplicated, so this went.
The final savings were around 56 bytes, with details shown below:
| Code Size | Method |
|-----------|------------------------------------------------|
| C7F | Start |
| C6C | Adding addtobufptr |
| C63 | Moving some foundptr references to bufptr |
| C5F | Remove copying of noun to roomptr |
| C5a | Adding addtofoundptr |
| C51 | Adding copybptofp (copying bufptr to foundptr) |
| C44 | Removing duplicate code |
Because I'm using two pointers (bufptr and foundptr) I have a duplication of code which I should probably try and remove:
.skipstringbp
{
ldy #0
lda (bufptr),y
jmp addtobufptr
}
; simple routine to add A to bufptr and save a few bytes
.addtobufptr
{
clc
adc bufptr
sta bufptr
bcc nooverflow
inc bufptr+1
.nooverflow rts
}
This could save another 17 bytes; I need to think it out better though...
Edit: As I posted this, I realised that I can remove the jmp statement as the code will fall through anyway. So another 6 bytes down - size at the moment is &C3E; with about &200 of this being the system engine messages.