cscg22-gearboy

CSCG 2022 Challenge 'Gearboy'
git clone https://git.sinitax.com/sinitax/cscg22-gearboy
Log | Files | Refs | sfeed.txt

palette.s (1942B)


      1        ;; SMS palette routines
      2
      3        .include        "global.s"
      4
      5        .title  "CRAM SMS Palettes"
      6        .module CRAMUtils
      7        .area   _HOME
      8
      9; void set_palette_entry(uint8_t palette, uint8_t entry, uint16_t rgb_data) __z88dk_callee;
     10_set_palette_entry::
     11        pop de
     12        pop bc
     13        ld hl, #.VDP_CRAM
     14        bit 0, c
     15        jr z, 1$
     16        set 4, b
     171$:
     18        ld c, b
     19        ld b, #0
     20        add hl, bc
     21        pop bc
     22
     23        ld a, i
     24        di
     25        ld a, l
     26        out (#.VDP_CMD), a
     27        ld a, h
     28        out (#.VDP_CMD), a
     29        ld a, c
     30        jp po, 2$
     31        ei
     322$:
     33        out (#.VDP_DATA), a
     34        
     35        ld h, d
     36        ld l, e
     37        jp (hl)
     38
     39; void set_palette(uint8_t first_palette, uint8_t nb_palettes, uint16_t *rgb_data) __z88dk_callee;
     40_set_palette::
     41        pop de
     42        pop bc
     43        ld hl, #.VDP_CRAM
     44        bit 0, c
     45        ld a, b
     46        ld bc, #0
     47        jr z, 1$
     48        ld c, #0x10
     491$:
     50        add hl, bc
     51
     52        ld c, a
     53
     54        DISABLE_VBLANK_COPY             ; switch OFF copy shadow SAT
     55
     56        ld a, i
     57        di
     58        ld a, l
     59        out (#.VDP_CMD), a
     60        ld a, h
     61        out (#.VDP_CMD), a
     62        jp po, 2$
     63        ei
     642$:
     65        ld a, c
     66        or a
     67        jr z, 3$
     68        
     69        pop hl
     70        ld c, #.VDP_DATA
     715$:
     72        ld b, #0x10
     734$:        
     74        outi
     75        jr nz, 4$
     76        
     77        dec a
     78        jr nz, 5$
     793$:        
     80        ENABLE_VBLANK_COPY              ; switch ON copy shadow SAT
     81
     82        ld h, d
     83        ld l, e
     84        jp (hl)
     85
     86.CRT_DEFAULT_PALETTE::
     87        .db 0b00111111
     88        .db 0b00101010
     89        .db 0b00010101
     90        .db 0b00000000
     91        .db 0b00000010
     92        .db 0b00001000
     93        .db 0b00100000
     94        .db 0b00001010
     95        .db 0b00101000
     96        .db 0b00100010
     97        .db 0b00000011
     98        .db 0b00001100
     99        .db 0b00110000
    100        .db 0b00001111
    101        .db 0b00111100
    102        .db 0b00110011
    103