Advertisement
Cthutu

Text Mode

Apr 8th, 2020
919
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. textMode:
  2.                 xor     a
  3.                 out     (IO_ULA),a
  4.  
  5.                 nextreg $6b,%11001001   ; Tilemap control
  6.                 nextreg $6b,%11001001   ; Tilemap control
  7.                 nextreg $6e,$00         ; Tilemap base offset                           $4000-$4f00 (80*24*2)
  8.                 nextreg $6f,$20         ; Tiles base offset                             $6000-$7000 (8*512)
  9.                 nextreg $4c,8           ; Transparency colour (bright black)
  10.                 nextreg $68,%10000000   ; Disable ULA output
  11.  
  12.                 ; Reset scrolling and clip window
  13.                 xor     a
  14.                 nextreg $1b,a
  15.                 nextreg $1b,159
  16.                 nextreg $1b,a
  17.                 nextreg $1b,255         ; Reset clip window
  18.                 nextreg $2f,a
  19.                 nextreg $30,a
  20.                 nextreg $31,a           ; Reset scrolling
  21.                 call    cls
  22.  
  23.                 ; Initialise the tilemap palette
  24.                 nextreg $43,%00110000   ; Set tilemap palette
  25.                 xor     a
  26.                 nextreg $40,a           ; Start from index 0
  27.                 ld      b,a             ; Colour (PPPIIII)
  28.                 ld      de,Palette
  29.  
  30. .l1            
  31.                 ; Set the paper colour
  32.                 ld      a,b
  33.                 and     $70
  34.                 swapnib                 ; a = 00000PPP
  35.                 ld      hl,de
  36.                 add     a,a
  37.                 add     hl,a
  38.                 ld      a,(hl)
  39.                 nextreg $44,a
  40.                 inc     hl
  41.                 ld      a,(hl)
  42.                 nextreg $44,a
  43.  
  44.                 ; Set the ink colour
  45.                 ld      a,b
  46.                 and     $f
  47.                 ld      hl,de
  48.                 add     a,a
  49.                 add     hl,a            ; HL = address of palette colour
  50.                 ld      a,(hl)
  51.                 nextreg $44,a
  52.                 inc     hl
  53.                 ld      a,(hl)
  54.                 nextreg $44,a
  55.  
  56.                 inc     b
  57.                 jp      p,.l1
  58.  
  59.                 ret
  60.  
  61. ;;----------------------------------------------------------------------------------------------------------------------
  62. ;; Palette control
  63.  
  64. Palette:                            ;       R       G       B
  65.                 db  %01001001, %0   ;       3       3       3       Dark grey
  66.                 db  %00000011, %1   ;       0       0       7       Bright blue
  67.                 db  %11100000, %0   ;       7       0       0       Bright red
  68.                 db  %00000000, %0   ;       0       0       0       Black           Black is here so we can have a black bg
  69.                 db  %00011100, %0   ;       0       7       0       Bright green
  70.                 db  %00011111, %1   ;       0       7       7       Bright cyan
  71.                 db  %11111100, %0   ;       7       7       0       Bright yellow
  72.                 db  %10110110, %1   ;       5       5       5       Light grey
  73.  
  74.                 db  %10100010, %1   ;       5       0       5       Magenta         We'll never have a magenta background
  75.                 db  %00000010, %1   ;       0       0       5       Blue
  76.                 db  %10100000, %0   ;       5       0       0       Red
  77.                 db  %11100011, %1   ;       7       0       7       Bright magenta
  78.                 db  %00010100, %0   ;       0       5       0       Green
  79.                 db  %00010110, %1   ;       0       5       5       Cyan
  80.                 db  %10110100, %0   ;       5       5       0       Yellow
  81.                 db  %11111111, %1   ;       7       7       7       White
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement