First Program |
Now if
you go back to the `Codes for sprite addresses` page you will see again
that the `Commodore 64` has only 8 hardware sprites, each sprite has a
code number to use to put in a list of its own register addresses to
display the sprite on screen. The 1st sprite that we are going to display is `sprite1` the code number for it is `01`, store `01` into address DO15 to switch the sprite on. Next get the code number for the design of the sprite that you are going to use (if your design starts at address 3500 then change the address (3500) into decimal and divide it by 64 decimal to get your design code number which should always be an integar number,then change the result into hex (`D4`)) and store it into address 07F8 (design address for sprite1), next since we are going to use `Manky`(4 colours) design which is in multicolour mode we have to switch on multicolour mode `for sprite1` by storing `01` into address D01C(address to switch multicolour on),next store `09` (code number for colour brown `Manky`s` hair and clothes) into address D025 (colour address which uses bits `01`) next store `0A` (code number for colour light red `Manky`s` face and arms) into address D027 (colour address which uses bits `10`) next store `07` (code number for colour yellow `Manky`s` eyes,teeth,finger tips and boots) into address D026 (colour address which uses bits `11`) next store `24` into address D000 (horizontal position address for sprite1) next store `CD` into address D001(vertical position address for sprite1). Here is the program to enter in the `Monitor` clear the screen first then type:- .A 4000 JSR$E544 (this command to clear the screen) .A 4003 JSR$5000 .A 4006 NOP .A 4007 JMP$4006 clear the screen again and type:- .A 5000 LDA#$01 .A 5002 STA$D015 .A 5005 LDA#$01 .A 5007 STA$D01C .A 500A LDA#$D4 .A 500C STA$07F8 .A 500F LDA#$0A .A 5011 STA$D027 .A 5014 LDA#$09 .A 5016 STA$D025 .A 5019 LDA#$07 .A 501B STA$D026 .A 501E LDA#$24 .A 5020 STA$D000 .A 5023 LDA#$CD .A 5025 STA$D001 .A 5028 LDA#$00 .A 502A STA$D020 .A 502D STA$D021 .A 5030 RTS Addresses 5028 to 502F colours the border and background black. If the sprite design data is not in the computer,place the tape marked "SPRITES" in your `datasette` then type:- .L"SPRITES",01,3500,3680 press `Return`. This will load `Manky` design data in memory (total tape counter 000 to 009). After the sprite design data is loaded clear the screen again then type .X and press `Return` you are now in`basic` (out of the `Monitor`).To run your program type SYS16384 then press `Return`. You can now see `Manky` on the bottom left hand screen. After the program is running you can return to `basic` by pressing `Stop/Restore` the same time. The next stage we can see if we can make `Manky` run on the spot. Make sure you are in the `Monitor`, clear the screen and type:- .A 4006 JMP$4100 Clear the screen and type:- .A 5030 STA$CE00 .A 5033 STA$CE01 .A 5036 RTS Clear the screen and type:- .A 4100 LDY#$0C .A 4102 LDX#$FF .A 4104 DEX .A 4105 BNE$4104 .A 4107 DEY .A 4108 BNE$4102 .A 410A JSR$5500 .A 410D JMP$4100 Clear the screen and type:- .A 5500 LDA$CE00 .A 5503 CMP#$00 .A 5505 BNE$551C .A 5507 LDX$CE01 .A 550A INX .A 550B STX$CE01 .A 550E CPX#$05 .A 5510 BNE$551C .A 5512 LDA#$D5 .A 5514 STA$07F8 .A 5517 LDA#$01 .A 5519 STA$CE00 .A 551C LDA$CE00 .A 551F CMP#$01 .A 5521 BNE$5538 .A 5523 LDX$CE01 .A 5526 INX .A 5527 STX$CE01 .A 552A CPX#$0A .A 552C BNE$5538 .A 552E LDA#$D6 .A 5530 STA$07F8 .A 5533 LDA#$02 .A 5535 STA$CE00 .A 5538 LDA$CE00 .A 553B CMP#$02 .A 553D BNE$5557 .A 553F LDX$CE01 .A 5542 DEX .A 5543 STX$CE01 .A 5546 CPX#$05 .A 5548 BNE$5557 .A 554A LDA#$D4 .A 554C STA$07F8 .A 554F LDA#$00 .A 5551 STA$CE00 .A 5554 STA$CE01 .A 5557 RTS Now to recall what we have written the program starts at 4000 and from 4006 jumps to 4100 the main program loop .All the addresses that are used are set to a given value from 5000 to 5036.From 4100 to 4109 slows down the program. 410A calls the design routine at 5500. 410D jumps back to 4100 to keep the program running.If you look at the design routine at 5500, CE01 is increased by `01` till it reaches the value of `05` then to `0A` then back to `05` then to `00`. If CE01 is `05` then the value in CE00 is `01` making the value in 07F8 `D5`. If CE01 is `0A` then the value in CE00 is `02` making the value in 07F8 `D6`. If CE01 is back to `05` then the value in CE00 is `00` making the value in 07F8 `D4`.The whole routine starts over again when CE00 and CE01 is set to `00`. Place a blank tape in your `datasette` then clear the screen and type:- .S"MANKY",01,3500,5558 then press `Return`. This saves all that you have typed in on to tape to load in later (total tape counter 000 to 061). Clear the screen type .X then press `Return` you are now in `basic` again to run your program type in SYS16384 and press `Return` as you will notice `Manky` is running on the spot. |