SHARE
TWEET

Untitled

a guest Sep 18th, 2019 134 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. =================================================
  2. c-code:
  3.    *MAPCTL = 0; // memory mapping for boot state
  4.     ptr = (u8*) 0xfd00; // timers and audio fd00
  5.     count = 0x40;//40
  6.     while (count--)
  7.     {
  8.         *ptr++ = 0;
  9.     }
  10. =================================================
  11. What it does:
  12. set mapping to 0 (all ROM, not RAM)
  13. then reset all registers at $fd00 (64).
  14. =================================================
  15.  
  16.     stz     $FFF9 ;fastes way! good
  17.    
  18.     ldx     #$FD  ;this sets helper variables
  19.     stz     L0050
  20.     stx     L0050+1
  21.     lda     #$40
  22.     sta     L0051
  23.     stz     L0051+1
  24.    
  25.    
  26.     bra     L00D9         ;weirdo: branch away for preparations first
  27.    
  28. L00D7:
  29.     lda     L0050
  30.     ldx     L0050+1
  31.     sta     regsave
  32.     stx     regsave+1  ;update regsave with helper variables
  33.     ina        
  34.     bne     L00DC
  35.     inx
  36. L00DC:
  37.     sta     L0050       ;update helper variables
  38.     stx     L0050+1
  39.     lda     #$00
  40.     sta     (regsave)  ;FINALLY write 0 to the register
  41.    
  42. L00D9:
  43.     lda     L0051   ;read helper variabels and store them in regsave
  44.     ldx     L0051+1
  45.     sta     regsave
  46.     stx     regsave+1
  47.     jsr     decax1     ;prepare counter
  48.     sta     L0051
  49.     stx     L0051+1
  50.     lda     regsave    ;...whatever
  51.     ora     regsave+1
  52.     bne     L00D7      ;branch back as part of the loop now!
  53. =================================================
  54. Assembler:
  55.     stz     $FFF9 ;identical to compiled part
  56.     ldx #$40
  57.     lda #0
  58. loop
  59.     sta $fd00,x ;you can't do STZ blabla,x
  60.     dex
  61.     bpl loop
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top