git.y1.nz

gbdk-2020

GameBoy Development Kit
download: https://git.y1.nz/archives/gbdk.tar.gz
README | Files | Log | Refs | LICENSE

gbdk-lib/libc/targets/mos6502/nes/fill_rect_bk_attributes.s

      1     .include    "global.s"
      2 
      3     .area   GBDKOVR (PAG, OVR)
      4     .fill_bkg_rect_attributes_padding::    .ds 5   ; Padding to avoid clash with _set_bkg_attribute_xy_nes16x16
      5     _fill_bkg_rect_attributes_PARM_3::
      6     _fill_win_rect_attributes_PARM_3::     .ds 1
      7     _fill_bkg_rect_attributes_PARM_4::
      8     _fill_win_rect_attributes_PARM_4::     .ds 1
      9     _fill_bkg_rect_attributes_PARM_5::
     10     _fill_win_rect_attributes_PARM_5::     .ds 1
     11     .xpos:                      .ds 1
     12     .ypos:                      .ds 1
     13     .xpos_save:                 .ds 1
     14     .width_save:                .ds 1
     15 
     16     .area   _HOME
     17 
     18 .ifdef NES_WINDOW_LAYER
     19 _fill_win_rect_attributes::
     20     tay
     21     lda *__current_vram_cfg_write
     22     pha
     23     ora #PPUHI_WIN
     24     sta *__current_vram_cfg_write
     25     tya
     26     jsr _fill_bkg_rect_attributes
     27     pla
     28     sta *__current_vram_cfg_write
     29     rts
     30 .endif
     31 
     32 _fill_bkg_rect_attributes::
     33     .define .width     "_fill_bkg_rect_attributes_PARM_3"
     34     .define .height    "_fill_bkg_rect_attributes_PARM_4"
     35     .define .attribute "_fill_bkg_rect_attributes_PARM_5"
     36     lsr
     37     sta *.xpos
     38     sta *.xpos_save
     39     txa
     40     lsr
     41     sta *.ypos
     42     ; width /= 2, round up
     43     lda *.width
     44     lsr
     45     adc #0
     46     sta *.width
     47     sta *.width_save
     48     ; height /= 2, round up
     49     lda *.height
     50     lsr
     51     adc #0
     52     sta *.height
     53     lda *.attribute
     54     sta *_set_bkg_attribute_xy_nes16x16_PARM_3
     55 1$:
     56     lda *.xpos
     57     and #(.DEVICE_SCREEN_BUFFER_WIDTH/2)-1
     58     ldx *.ypos
     59 .ifdef NES_WINDOW_LAYER
     60     bit *__current_vram_cfg_write    ; Note: Assumes PPUHI_WIN = 0x80
     61     bpl 2$
     62     jsr _set_win_attribute_xy_nes16x16
     63     jmp 3$
     64 2$:
     65 .endif
     66     jsr _set_bkg_attribute_xy_nes16x16
     67 3$:
     68     inc *.xpos
     69     dec *.width
     70     bne 1$
     71     lda *.xpos_save
     72     sta *.xpos
     73     lda *.width_save
     74     sta *.width
     75     inc *.ypos
     76     lda *.ypos
     77     cmp #(.DEVICE_SCREEN_BUFFER_HEIGHT/2)
     78     bne 0$
     79     lda #0
     80 0$:
     81     sta *.ypos
     82     dec *.height
     83     bne 1$
     84     rts

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.