Sunday, 17 March 2019

Project Set-Up

While continuing to work on my screen editor, ChillED, I've decided to set-up a work project folder containing everything needed for the game.  My usual way of saving things means direct to my (paid for) Dropbox folder, so I get automatic backups with version history in case as well as being able to access all my files from any computer I sign in to - I can code in work too!

The project folder will contain all code, data and work files (sprites, charsets, music, ChillED screens), a copy of both ACME cross assembler and Exomizer (for assembling and compressing the game) and a .bat file that turns my source text file into a C64 executable by calling the afore-mentioned ACME.

While doing this, I also started a new source code file (thus begins the code for the game) and copied in my usual set-up code that, for Chiller 2, looks a little like this...


 ; the name and file format for the assembled program  
   
           !to "chiller2.prg",cbm  
   
 ; position of the raster interrupt(s) on-screen  
 ; 'rp' is short for 'raster position'! duh!  
   
 raster_1_pos     = $00       ; start of screen  
 
 ; some zp label assignments (variables)  
   
 raster_num       = $50       ; raster counter stores which split we are working in  
 sync             = $51       ; interupt sync variable  
   
 ; add a BASIC startline (SYS 16384) for auto-run after loading  
   
           * = $0801  
           !word code_entry-2  
           !byte $00,$00,$9e  
           !text "16384"  
           !byte $00,$00,$00  
   
 ; entry point for the code  
   
           * = $4000          ; hence sys 16384!  
                       
 code_entry  
   
 ; stop interrupts, disable the roms and set up nmi and irq interrupt pointers
   
           sei                ; disable maskable IRQs  
             
           lda #$35           ; kill EVERYTHING (MWHAHA!) except $f000-$ffff
           sta $01  
             
 ; setup nmi  
   
           lda #<nmi       ; some nmi stuff  
           sta $fffa  
           lda #>nmi  
           sta $fffb  
             
 ; setup irq's  
   
           lda #<int       ; some irq stuff  
           sta $fffe  
           lda #>int  
           sta $ffff  
   
           lda #$7f  
           sta $dc0d          ; disable timer interrupts which can be generated by the two CIA chips
           sta $dd0d          ; the kernal uses such an interrupt to flash the cursor and scan
                              ; the keyboard, so we better stop it  
   
           lda $dc0d          ; by reading this two registers we negate any pending CIA irqs
           lda $dd0d          ; if we don't do this, a pending CIA irq might occur after we
                              ; finish setting up our irq. we don't want that to happen
   
           lda #raster_1_pos  ; starting point of raster on screen ($00)  
           sta $d012  
   
           lda #$1b           ; as there are more than 256 rasterlines, the topmost bit of $d011 serves as
           sta $d011          ; the 9th bit for the rasterline we want our irq to be triggered  
             
           lda #$01  
           sta $d019          ; clear interupt bit  
           sta $d01a          ; tell vicii to generate interupt  
   
           lda #$35           ; turn off basic and kernal rom thus  
           sta $01            ; c64 now sees RAM everywhere except at $d000-$e000  
             
           lda #$18           ; use our custom font charset  
           sta $d018  
   
           cli


What on earth is all that?!?!

Quite simply, it's some code that tells the ACME cross-assembler to set the C64 up and that we're taking full control of the machine so that we will have all 64K available for the project.  This code does things like wiping out all the ROM characters and disabling the C64's internal routines (Kernal) that detects and controls things like I/O functions (keyboard detections and so on).

This code is also setting up a couple of labels/variables for controlling the raster, as well as generating an SYS call so that future builds will create an executable that will autorun when loaded.

Other than that, the code is fairly well commented already!  It is missing some things such as memory locations assignements for where the charset. music, sprites and so on will be, but since I haven't decided on this yet, the code isn't in!

I must give credit to Jason 'T.M.R' Kelk who showed me how to set this up originally and Jon 'Moloch' Mines for providing further explanations.

Next diary entry...


No comments:

Post a Comment