; *************************************************************************** ; *************************************************************************** ; ; chrmap.asm ; ; A simple map system based on 8x8 characters (aka "tiles") in BAT format. ; ; Copyright John Brandwood 2025. ; ; Distributed under the Boost Software License, Version 1.0. ; (See accompanying file LICENSE_1_0.txt or copy at ; http://www.boost.org/LICENSE_1_0.txt) ; ; *************************************************************************** ; *************************************************************************** ; ; The maximum X and Y size for chrmaps is 256 characters (2048 pixels). ; ; The maximum total size for a chrmap is 16KBytes, which allows for maps up ; to 256x32 tiles (2048x256 pixels). ; ; *************************************************************************** ; *************************************************************************** ; ; Include dependancies ... ; include "blkmap.asm" ; This defines the variables. ; ; Chrmaps in BAT format normally address all of VRAM from $0400..$7FFF, but ; they can be limited to use the 32KByte of characters in VRAM $1000..$4FFF ; which then frees up 2-bits for flag information for each character in the ; BAT entry. ; ; These 2-bits are perfect for using as collision information in game maps, ; allowing storage of states like transparent, solid, up-slope, down-slope. ; ; Typically this flag information is set by the map conversion tools from a ; seperate "collision" map layer. ; .ifndef CHRMAP_BAT_FLAG CHRMAP_BAT_FLAG = 0 ; (0 or 1) .endif ; ; ; chrmap_group .procgroup ; *************************************************************************** ; *************************************************************************** ; ; _draw_bat - Draw the entire screen at the current coordinates. ; _sgx_draw_bat - Draw the entire screen at the current coordinates. ; ; void __fastcall draw_bat( void ); ; void __fastcall sgx_draw_bat( void ); ; .if SUPPORT_SGX _sgx_draw_bat .proc ldx #SGX_VDC_OFFSET ; Offset to SGX VDC. db $F0 ; Turn "clx" into a "beq". .ref _draw_bat .endp .endif _draw_bat .proc clx ; Offset to PCE VDC. tma3 ; Preserve MPR3..MPR5. pha tma4 pha tma5 pha jsr bat_pxl_2_chr ; Set up the draw coordinates. lda , unsigned char tile_y, unsigned char tile_w, unsigned char tile_h ); ; void __fastcall sgx_blit_bat( unsigned char tile_x, unsigned char tile_y, unsigned char tile_w, unsigned char tile_h ); ; ; Normally you'd just use _draw_bat() and _scroll_bat(), but for those folks ; who really wish to take manual control, you can use this. ; .if SUPPORT_SGX _sgx_blit_bat .proc ldx #SGX_VDC_OFFSET ; Offset to SGX VDC. db $F0 ; Turn "clx" into a "beq". .ref _blit_bat .endp .endif _blit_bat .proc clx ; Offset to PCE VDC. tma3 ; Preserve MPR3..MPR5. pha tma4 pha tma5 pha lda vdc_map_option, x ; Preserve current map options. pha ora #MAP_UNALIGNED_X | MAP_UNALIGNED_Y sta vdc_map_option, x jsr bat_pxl_2_chr ; Set up the draw coordinates. lda = old_x. adc vdc_map_draw_w, x ; Usually (SCR_WIDTH / 8) + 1. dec a .moved: pha ; Push chr_x in map section. bit vdc_map_option, x ; Set bit7 to disable aligning bmi !+ ; BAT X with the map X. and vdc_bat_x_mask, x sta = old_y. adc vdc_map_draw_h, x ; Usually (SCR_HEIGHT / 8) + 1. dec a .moved: tay ; Y = chr_y in map section. bit vdc_map_option, x ; Set bit6 to disable aligning bvs !+ ; BAT Y with the map Y. and vdc_bat_y_mask, x sta