Advertisement
paul_nicholls

Untitled

Dec 7th, 2024 (edited)
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. :BasicUpstart2(_start_)
  2.  
  3. * = $080d "main code"
  4.  
  5. .const LOADER_ADDR = 828
  6. .const srcPntr     = $fb
  7. .const dstPntr     = $fd
  8.  
  9. _start_: {
  10.   jsr displayScreen
  11.   jsr relocateLoader
  12.   jmp LOADER_ADDR
  13. }
  14.  
  15. relocateLoader: {
  16.   lda #<_loader_start
  17.   sta srcPntr+0
  18.   lda #>_loader_start
  19.   sta srcPntr+1
  20.  
  21.   lda #<LOADER_ADDR
  22.   sta dstPntr+0
  23.   lda #>LOADER_ADDR
  24.   sta dstPntr+1
  25.  
  26.   ldx #_loader_end-_loader_start
  27.   ldy #0
  28. loaderLoop:
  29.   lda (srcPntr),y
  30.   sta (dstPntr),y
  31.  
  32.   inc srcPntr+0
  33.   bne !+
  34.   inc srcPntr+1
  35. !:
  36.   inc dstPntr+0
  37.   bne !+
  38.   inc dstPntr+1
  39. !:
  40.   dex
  41.   bne loaderLoop
  42.  
  43.   rts
  44. }
  45.  
  46. clearScreen: {
  47.   lda #0
  48.   ldx #$00
  49. clearLoop:
  50.   sta $d800,x
  51.   sta $d900,x
  52.   sta $da00,x
  53.   sta $db00,x
  54.   inx
  55.   bne clearLoop
  56.   rts
  57. }
  58.  
  59. displayScreen: {
  60.   jsr clearScreen
  61.  
  62.   lda #$0b
  63.   sta $d011
  64.   lda #$00
  65.   sta $d020
  66.   lda $4710
  67.   sta $d021
  68.  
  69.   ldx #$00
  70. copyLoop:
  71.   lda $3f40,x
  72.   sta $0400,x
  73.   lda $4040,x
  74.   sta $0500,x
  75.   lda $4140,x
  76.   sta $0600,x
  77.   lda $4240,x
  78.   sta $0700,x
  79.   lda $4328,x
  80.   sta $d800,x
  81.   lda $4428,x
  82.   sta $d900,x
  83.   lda $4528,x
  84.   sta $da00,x
  85.   lda $4628,x
  86.   sta $db00,x
  87.   inx
  88.   bne copyLoop
  89.  
  90.   lda #$3b
  91.   sta $d011
  92.   lda #$18
  93.   sta $d018
  94.   lda #$d8
  95.   sta $d016
  96.   rts
  97. }
  98.  
  99. _loader_start:
  100. .pseudopc LOADER_ADDR {
  101.   loadAndRunGame:
  102.     lda #fileName_end - fileName
  103.     ldx #<fileName
  104.     ldy #>fileName
  105.     jsr $FFBD     // call SETNAM
  106.     lda #$01
  107.     ldx $BA       // last used device number
  108.     bne skip
  109.     ldx #$08      // default to device 8
  110.   skip:
  111.     ldy #$01      // not $01 means: load to address stored in file
  112.     jsr $FFBA     // call SETLFS
  113.  
  114.     lda #$00      // $00 means: load to memory (not verify)
  115.     jsr $FFD5     // call LOAD
  116.     bcs error     // if carry set, a load error has happened
  117.  
  118.     // start program
  119.     jmp $080d
  120.   error:
  121.     sta $d020
  122.   // Accumulator contains BASIC error code;
  123.   // most likely errors:
  124.   // A = $05 (DEVICE NOT PRESENT)
  125.   // A = $04 (FILE NOT FOUND)
  126.   // A = $1D (LOAD ERROR)
  127.   // A = $00 (BREAK, RUN/STOP has been pressed during loading)
  128.     rts
  129.   fileName:
  130.     .encoding "ascii"
  131.     .text "ROGUEISH"
  132.   fileName_end:
  133. }
  134. _loader_end:
  135.  
  136.  
  137. * = $2000 "image"
  138. image:{
  139.   .import binary "graphics/ROGUEish titlescreen.koa",2
  140. }
  141.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement