cscg22-gearboy

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

palette.s (2155B)


      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        sla b
     19        ld c, b
     20        ld b, #0
     21        add hl, bc
     22        pop bc
     23
     24        ld a, i
     25        di
     26        ld a, l
     27        out (#.VDP_CMD), a
     28        ld a, h
     29        out (#.VDP_CMD), a
     30        ld a, c
     31        out (#.VDP_DATA), a
     32        jr 3$
     333$:
     34        ld a, b
     35        out (#.VDP_DATA), a
     36        jp po, 2$
     37        ei
     382$:        
     39        ld h, d
     40        ld l, e
     41        jp (hl)
     42
     43; void set_palette(uint8_t first_palette, uint8_t nb_palettes, uint16_t *rgb_data) __z88dk_callee;
     44_set_palette::
     45        pop de
     46        pop bc
     47        ld hl, #.VDP_CRAM
     48        bit 0, c
     49        ld a, b
     50        ld bc, #0
     51        jr z, 1$
     52        ld c, #0x20
     531$:
     54        add hl, bc
     55        
     56        ld c, a
     57
     58        DISABLE_VBLANK_COPY              ; switch OFF copy shadow SAT
     59
     60        ld a, i
     61        di
     62        ld a, l
     63        out (#.VDP_CMD), a
     64        ld a, h
     65        out (#.VDP_CMD), a
     66        jp po, 2$
     67        ei
     682$:
     69        ld a, c
     70        or a
     71        jr z, 3$
     72        
     73        pop hl
     74        ld c, #.VDP_DATA
     755$:
     76        ld b, #0x20
     774$:        
     78        outi
     79        jr nz, 4$
     80        
     81        dec a
     82        jr nz, 5$
     833$:        
     84        ENABLE_VBLANK_COPY               ; switch ON copy shadow SAT
     85
     86        ld h, d
     87        ld l, e
     88        jp (hl)
     89
     90.CRT_DEFAULT_PALETTE::
     91        .dw 0b0000111111111111
     92        .dw 0b0000100010001000
     93        .dw 0b0000010001000100
     94        .dw 0b0000000000000000
     95        .dw 0b0000000000001000
     96        .dw 0b0000000010000000
     97        .dw 0b0000100000000000
     98        .dw 0b0000000010001000
     99        .dw 0b0000100010000000
    100        .dw 0b0000100000001000
    101        .dw 0b0000000000001111
    102        .dw 0b0000000011110000
    103        .dw 0b0000111100000000
    104        .dw 0b0000000011111111
    105        .dw 0b0000111111110000
    106        .dw 0b0000111100001111
    107