*---------------------------------------------------------------------- * File Name: print.asm * * Copyright (c) 1994 Sega of America, Inc. All Rights Reserved. * * Author(s): Unni Pillai * Date: 6-03-94 * Description: * * History: * *---------------------------------------------------------------------*/ SPACE equ 32 nolist section .text lbeven: include "vdp.h" include "vdp.i" include "mdcon.mac" xref KTable1 list opt mex *-------------------------------------------------------------------- * _B_PRINT: PRINT ASCII MESSAGE * * void _B_PRINT( ) * ascii message print ( end code $00 ) * * in d0.l : column_line * a1.l : address * * out d0.l : column _line * a1.l : -- * * MODS * name date comments * ---- -------- ------------------------------------- * UP 06/02/94 created *---------------------------------------------------------------------- xdef B_PRINT dc.l 0 B_PRINT: movem.l d1-d2/a2-a3,-(sp) move.l #$C00004,a2 move.l #$C00000,a3 moveq #0,d1 move.w d0,d1 lsl.w #6,d1 swap d0 add.w d0,d1 add.l d1,d1 add.l #ScrollA,d1 lsl.l #2,d1 lsr.w #2,d1 or.w #$4000,d1 swap d1 move.l d1,(a2) moveq #1,d2 sub.w #$0020,d2 B_PRINT_01: moveq #0,d1 move.b (a1)+,d1 beq B_PRINT_EXIT add.w d2,d1 move.w d1,(a3) addq.w #1,d0 bra B_PRINT_01 B_PRINT_EXIT: swap d0 movem.l (sp)+,d1-d2/a2-a3 rts *-------------------------------------------------------------------- * _B_PUTC: PRINT SINGLE ASCII CHARACTER * * void _B_PUTC( ) * ascii print ( single character put ) * * in d0.l : column_line * d1.w : character * * out d0.l : column _line * d1.l : -- * MODS * name date comments * ---- -------- ------------------------------------- * UP 06/02/94 created *---------------------------------------------------------------------- xdef B_PUTC dc.l 0 B_PUTC: movem.l d1-d2/a2-a3,-(sp) lea VDPControl,a2 lea VDPData,a3 moveq #0,d2 move.w d0,d2 lsl.w #6,d2 swap d0 add.w d0,d2 add.l d2,d2 add.l #ScrollA,d2 lsl.l #2,d2 lsr.w #2,d2 or.w #$4000,d2 swap d2 move.l d2,(a2) or.w #chrbnk,d1 move.w d1,(a3) addq.w #1,d0 swap d0 movem.l (sp)+,d1-d2/a2-a3 rts *-------------------------------------------------------------------- * _binhex: convert binary to hex * * void _binhex( ) * bin to hex convert * * in d0.w : data (4bits*4 data) * a0.l : textbuffer pointer * * out d0.l : -- * a0.l : next pointer * * MODS * name date comments * ---- -------- ------------------------------------- * UP 06/02/94 created *---------------------------------------------------------------------- xdef binhex dc.l 0 binhex: movem.l d0-d2,-(sp) moveq #4-1,d2 binhex_00: rol.w #4,d0 move.b d0,d1 and.b #$0f,d1 cmp.b #10,d1 blt binhex_01 addq.b #7,d1 binhex_01: add.b #$30,d1 move.b d1,(a0)+ dbra d2,binhex_00 movem.l (sp)+,d0-d2 rts xref SetVRAMWrite ************************************************************************* * CONSOLE ROUTINE * * _console: Prints stuff on screen * * void _console( ) * MODS * name date comments * ---- -------- ------------------------------------- * UP 06/17/94 *---------------------------------------------------------------------- ************************************************************************* xdef console dc.l 0 console: st VDPLock ;do not allow interrupts to use VDP move.l #console,-(sp) ;stack return address moveq #0,d0 ;clear d0 move.b (a0)+,d0 ;get command (or character code) byte cmp.b #SPACE,d0 ;compare with space character bhs.s co_printchar ;print a character if space or more add.w d0,d0 ;*2 add.w d0,d0 ;*4 (long word index) move.l co_commands(pc,d0.w),-(sp) ;stack command address rts ;EXECUTE command co_printchar add.w chrattr,d0 ;add chaarcter attribute move.w d0,VDPData ;put cell attribute in cell map (VRAM) rts co_commands dc.l co_stop,co_skip,co_screen,co_posxy dc.l co_attr,co_call co_stop addq.w #4,sp ;strip return address (CONSOLE) sf VDPLock ;flag interrupt routine can use VDP rts ;return from console co_screen move.w (a0)+,scrbase ;set screen base address co_skip rts co_posxy moveq #0,d0 ;clear d0 moveq #0,d1 ;clear d1 move.b (a0)+,d0 ;get x (byte) move.b (a0)+,d1 ;get y (byte) mulu CellMapCols,d1 ;scale by width of scroll add.w d1,d0 ;add x to form index add.w d0,d0 ;indexing words (cell map) add.w scrbase,d0 ;add base of screen jmp SetVRAMWrite ;set the screen address up in VDP co_attr move.w (a0)+,d0 ;get character attribute sub.w #SPACE,d0 ;subtract first character code in character set move.w d0,chrattr ;save character attribute rts co_call move.l (a0)+,a1 ;get code address move.l a0,-(sp) ;save console PC jsr (a1) ;call code move.l (sp)+,a0 ;get console PC rts ;back to console