include "cpu/68000/include/common.inc" global tile_8x8_viewer_handler COLUMN_START equ SCREEN_START_X ROW_START equ SCREEN_START_Y + 6 section code ; params: ; d0 = tile offset ; d1 = offset mask ; a0 = seek_xy function ; a1 = draw_tile function tile_8x8_viewer_handler: move.w d0, (r_tile_offset) move.w d1, (r_tile_offset_mask) move.l a0, (r_seek_xy_cb) move.l a1, (r_draw_tile_cb) SEEK_XY SCREEN_START_X, (SCREEN_START_Y + 2) lea d_str_offset, a0 RSUB print_string jsr print_b2_return_to_menu SEEK_XY (COLUMN_START + 2), (SCREEN_START_Y + 4) lea d_str_0f, a0 RSUB print_string .loop_redraw: move.w (r_tile_offset), d6 move.w (r_tile_offset_mask), d1 and.w d1, d6 move.w d6, (r_tile_offset) moveq #15, d5 ; number of rows - 1 moveq #ROW_START, d2 ; current row number lea d_str_0f, a1 .loop_next_row: moveq #COLUMN_START, d3 ; reset with each row move.l d3, d0 move.l d2, d1 RSUB screen_seek_xy move.b (a1)+, d0 RSUB print_char ; print the row header char addq.b #2, d3 ; skip from header to first tile position for the row moveq #15, d4 ; number of bytes per row - 1 .loop_next_byte: move.l d3, d0 move.l d2, d1 move.l (r_seek_xy_cb), a0 jsr (a0) move.w d6, d0 move.l (r_draw_tile_cb), a0 jsr (a0) addq.b #1, d3 ; next position over addq.b #1, d6 ; next byte to print dbra d4, .loop_next_byte addq.b #1, d2 ; next row dbra d5, .loop_next_row .loop_input: WATCHDOG SEEK_XY (SCREEN_START_X + 8), (SCREEN_START_Y + 2) move.w r_tile_offset, d0 RSUB print_hex_word bsr input_update move.b r_input_edge, d0 btst #INPUT_UP_BIT, d0 beq .up_not_pressed add.w #$100, r_tile_offset bra .loop_redraw .up_not_pressed: btst #INPUT_DOWN_BIT, d0 beq .down_not_pressed sub.w #$100, r_tile_offset bra .loop_redraw .down_not_pressed: btst #INPUT_LEFT_BIT, d0 beq .left_not_pressed sub.w #$1000, r_tile_offset bra .loop_redraw .left_not_pressed: btst #INPUT_RIGHT_BIT, d0 beq .right_not_pressed add.w #$1000, r_tile_offset bra .loop_redraw .right_not_pressed: btst #INPUT_B2_BIT, d0 beq .loop_input rts section data align 1 d_str_offset: STRING <"OFFSET",CHAR_COLON> d_str_0f: STRING "0123456789ABCDEF" section bss align 1 r_seek_xy_cb: dcb.l 1 r_draw_tile_cb: dcb.l 1 r_tile_offset: dcb.w 1 r_tile_offset_mask: dcb.w 1