include "cpu/konami2/include/common.inc" global print_bits_byte_dsub global print_byte_dsub global print_char_dsub global print_clear_line_dsub global print_hex_nibble_dsub global print_hex_byte_dsub global print_hex_word_dsub global print_string_dsub section code ; params: ; a = byte ; x = location in tile ram print_bits_byte_dsub: ; printing backwards leax 7, x ldb #$8 .loop_next_nibble: tfr b, y tfr a, b andb #$1 addb #$60 stb ,x leax -1, x lsra tfr y, b decb bne .loop_next_nibble DSUB_RETURN ; params ; a = byte ; x = start location in tile ram print_byte_dsub: sta , x DSUB_RETURN ; params ; a = char ; x = start location in tile ram print_char_dsub: cmpa #'0' blt .not_digit cmpa #'9' bgt .not_digit adda #$30 .not_digit: sta , x DSUB_RETURN ; params: ; x = start location in tile ram print_clear_line_dsub: CHAR_REPEAT #$20, #32 DSUB_RETURN ; params: ; a = nibble (lower) ; x = start location in tile ram print_hex_nibble_dsub: anda #$f cmpa #$9 ble .is_digit adda #'A' - $a bra .do_print .is_digit: adda #$60 .do_print: sta , x DSUB_RETURN ; params: ; a = byte ; x = start location in tile ram ; b should not be touched, needed for work ram errors print_hex_byte_dsub: ; printing backwards leax 1, x rept 2 inline tfr a, y anda #$f cmpa #$9 ble .is_digit adda #'A' - $a bra .do_print .is_digit: adda #$60 .do_print: sta , x leax -1, x tfr y, a lsra lsra lsra lsra einline endr DSUB_RETURN ; params: ; d = word ; x = start location in tile ram print_hex_word_dsub: ; printing backwards leax 3, x rept 4 inline tfr b, y andb #$f cmpb #$9 ble .is_digit addb #'A' - $a bra .do_print .is_digit: addb #$60 .do_print: stb , x leax -1, x tfr y, b lsra rorb lsra rorb lsra rorb lsra rorb einline endr DSUB_RETURN ; params: ; x = start location in tile ram ; y = start address of string print_string_dsub: lda ,y+ .loop_next_char: cmpa #'0' blt .not_digit cmpa #'9' bgt .not_digit adda #$30 .not_digit: sta ,x+ lda ,y+ bne .loop_next_char DSUB_RETURN