Name: Error Descr: Assembler include for debugging Author: Klas Sandén klas.sanden@swipnet.se http://www.edu.isy.liu.se/~c94klasa Bugs: What it is: ----------- This code changes the trap vectors to give importent debug information. The registers d0-d7/a0-a7 is displayed if there occurs an exception. It's also possible to create a call stack which keeps track of where the error ocuured. Of course traps can be generated with info for the programmer. How it works ------------ This a nasty piece of work, which takes controll of the system interrupt. The vb-int is used to control the programs output. The blt-int is allowed to continue. I'm not sure what's done to other interrupts, but it works fine on my computer. I'M NOT RESPONSIBLE FOR ANY BROKEN EQUIPMENT WHILE USING THIS CODE. How to include: --------------- I usually have 3 three type of sections as follows 1. Definitions - insert the error.i file here 2. Code - insert the error_code file here 3. Data - insert the error_data file here Parameters ---------- _DEBUG - The master enable parameter. Without this set no error code is created. EX SET _DEBUG 1 Starting and stopping --------------------- err_init - Changes the contents of some trap-vectors. err_close - Restores the trapvectors NOTE: If tou modify the vectors,for example the level 3, you have to be sure that the order is correct, for example bsr err_init bsr your_change bsr main bsr your_restore bsr err_close or bsr your_change bsr err_init bsr main bsr err_close bsr your_restore is correct, but not bsr err_init my first bsr your_change then tour bsr main bsr err_close my first agin, will not work bsr your_restore How to use the macros: ---------------------- err_text - simple text string generation, link to a0 when traping \1 - Error text(must be capital letters) debug_head - generates a debughead which adds routine to call stack \1 - Name of routine to be checked debug_call - branch to the routines head. \1 - branchtype(jsr/jmp etc) \2 - routine name, without the debug sufix debug_address - links a register to the debug head \1 - instruction(move,lea etc) \2 - routine name, without sufix debug_inst - Intruction to be executed only in debug mode \1 - instruction name \2 - data Ex debug_inst add.w,#10,d0 Example ----------------------------------------------------------------------------- ------------------------------------------------------------------------------ ;This marks debug code ------------------------------------------------------------------------------ ************************************************* * * * 3d * * * * Klas 'Koma' Sandén 1996-07-07 * * * * TO FIX * * * * Cliping_z one div/clip * * Cliping_3d table for t muls * * * ************************************************* ****************************************************************************** * * CED executer data * * #ASSEM# * #FIELD#: c:phxass >t:gen.err FROM &fn TO exe:&n ERRORS 0 DS DL CASE &nl * #FIELD#: rx rexx:ced/phx/go2err.ced t:gen.err * #CEXEND# * * #NEXTERR# * #FIELD#: rx rexx:ced/phx/go2err.ced t:gen.err * #CEXEND# * * #EXECUTE# * #FIELD#: exe:&n >nil: * #CEXEND# * * #DEBUG# * #FIELD#: c:bdebug exe:&n * #CEXEND# * * #COOMAND# * #FIELD#: c:monam exe:&n * #CEXEND# * ****************************************************************************** _SCREEN_WIDTH = 80 _SCREEN_HEIGHT = 128 _SCREEN_DEPTH = 6 _SCREEN_ANT = 2 _SCREEN_RES = 22 _SCREEN_BG = $202 _CHUNKY_WIDTH equ 160 _CHUNKY_HEIGHT equ 128 _CHUNKY_ANT equ 2 _CHUNKY_X equ _CHUNKY_WIDTH*4 _CHUNKY_Y equ _CHUNKY_HEIGHT _VIEW_MAX_X = _CHUNKY_WIDTH/2-1-3 _VIEW_MIN_X = -_CHUNKY_WIDTH/2+3 _VIEW_MAX_Y = _CHUNKY_HEIGHT/2-3 _VIEW_MIN_Y = -_CHUNKY_HEIGHT/2+3 ****************************************************************************** * * Assembler code parameters * * Assembler * _DEVPAC = 1 _PHX = 2 _BARFLY = 3 _ASSEMBLER = _PHX * Phx options * IFEQ ( _ASSEMBLER - _PHX ) MACHINE 68030 ;PHXASS options FPU ;matrix44_fixbase ENDIF * Cpu data * _CPU = 68030 _FPU = 68882 * Debug code * ------------------------------------------------------------------------------ _DEBUG SET 1 ; enable debug code generation ------------------------------------------------------------------------------ _ERROR_CHECK SET 1 * Render code * _HAM8_FADE = 2 ;_DIRTY_RENDER SET 1 ;_CLEAR_CHUNKY SET 1 * Rotation code * _ROT_ABS = 0 _ROT_DELTA = 1 _ROT_QUAT = 2 _ROTATION_TYPE SET _ROT_DELTA ; _INTENA_USER = 1<<3+1<<5+1<<6+1<<11+1<<14 ;_MOUSE_CONTROL _MOUSE_SENSITIVITY = 6 ;8 max, 0 min include 3d:3d.i include aga3:grundkoder3/grundmacros.i ------------------------------------------------------------------------------ include aga3:grundkoder3/error.i ;include the macros ------------------------------------------------------------------------------ IFD QUATERNIONS include aga3:grundkoder3/quaternions.i ELSE include aga3:grundkoder3/matrix44.i ENDC section code,code bsr blitter_done ------------------------------------------------------------------------------ debug_head MAIN_START ;adds main_start to call stack ------------------------------------------------------------------------------ main_start movem.l d0-d7/a0-a6,-(sp) bsr main_init bsr world_matrix_init lea.l world_matrix,a0 bsr matrix44_fixbase_Shift IFD _QUATERNIONS bsr world_quat_init ELSE bsr world_matrix_init bsr world_matrix_init_reverse ENDC bsr light_update_vb bsr update bsr player_update_vb bsr player_check bsr int3_init jsr err_init ------------------------------------------------------------------------------ lea.l .start,a0 ;message to display,see below trap #_ERR ;generate programer trap ------------------------------------------------------------------------------ bsr main_loop jsr err_close bsr int3_close bsr main_close add.l #4,error_stack_ptr movem.l (sp)+,d0-d7/a0-a6 rts ------------------------------------------------------------------------------ .start ;see above dc.b "START!",-1 even ------------------------------------------------------------------------------ main_init bsr chunky_init bsr ham8_init lea.l ham8_plist,a6 bsr chunky_ham8_init_list bsr player_init bsr player_want_calc bsr c2p_init rts c2p_init move.w #_CHUNKY_X,d0 move.w #_CHUNKY_Y,d1 clr.w d3 move.l #_SCREEN_WIDTH*_SCREEN_HEIGHT,d5 jsr c2p1x1_64_cpu3blit1_queue_init rts main_close rts main_loop .loop cmp.b #$39,$bfec01 beq .end tst.l vb_flag beq .loop IFD _CLEAR_CHUNKY bsr chunky_clear ENDC ****************************************************************************** move.l chunky0,a0 move.l screen1,a1 jsr c2p1x1_64_cpu3blit1_queue ****************************************************************************** IFD _QUATERNIONS bsr world_quat_init ELSE bsr world_matrix_init bsr world_matrix_init_reverse ENDC ------------------------------------------------------------------------------ debug_call bsr,update ;call the debug header if enabled ------------------------------------------------------------------------------ bsr player_check ****************************************************************************** .wb tst.l blt_que_ready beq .wb ****************************************************************************** bsr chunky_swap bsr screen_swap clr.l vb_flag bra .loop .end rts vb_update bsr player_update_vb bsr light_update_vb rts _VB_DO = vb_update ------------------------------------------------------------------------------ debug_head UPDATE ;create the debug header ------------------------------------------------------------------------------ update move.l sector_current,a0 lea.l render_list,a2 move.w #_VIEW_MAX_X,d0 move.w #_VIEW_MIN_X,d1 move.w #_VIEW_MAX_Y,d2 move.w #_VIEW_MIN_Y,d3 ------------------------------------------------------------------------------ debug_call bsr,sector_render_add ; if (debug set): ; bsr sector_render_add_debug ; else: bsr sector_render_add debug_call bsr,sector_render ------------------------------------------------------------------------------ add.w #1,main_nr move.w main_nr,d0 ; and.w #$f,d0 ; cmp.w #$f,d0 ; bne .skip .skip ; add.w #1,world_beta rts IFD QUATERNIONS include aga3:grundkoder3/quaternion.asm ELSE include aga3:grundkoder3/matrix44.asm ENDC include aga3:grundkoder3/HAM8-screen_code.asm include aga3:grundkoder3/HAM8-chunky.code.asm include aga3:Grundkoder3/c2p1x1_blit_code.asm include 3d:light/code.asm include 3d:Render/code.asm include 3d:sector/code.asm include 3d:surface/code.asm include 3d:exit/code.asm include 3d:rotation/code.asm include 3d:player/code.asm include 3d:world/code.asm include 3d:cliping/cliping_3d.asm include 3d:cliping/cliping_z.asm include aga3:grundkoder3/blitter_done.asm ------------------------------------------------------------------------------ include aga3:grundkoder3/error_code.asm ------------------------------------------------------------------------------ main_nr dc.w 10 sector_current dc.l _SECTOR_START render_list_last dc.l 0 dc.l -1 ;end render_list dcb.l 200*5,3 ;surface list surface *,xmax,xmin,ymax,ymin ham8_plist dc.l pattern_def,128*4,128 dc.l pattern_floor,128*4,128 dc.l pattern_floor2,128*4,128 dc.l pattern_roof,128*4,128 dc.l pattern_roof2,128*4,128 dc.l pattern_wall2,128*4,128 dc.l pattern_endwall,128*4,128 dc.l 0 include "code:gfx/3d/worlds/box4.asm" _W0X = _SECTOR_START_X _W0Y = _SECTOR_START_Y _W0Z = _SECTOR_START_Z include 3d:cliping/data.asm include 3d:render/data.asm include 3d:light/data.asm ------------------------------------------------------------------------------ include aga3:grundkoder3/error_data.asm ------------------------------------------------------------------------------ include 3d:rotation/data.asm include 3d:world/data.asm include 3d:player/data.asm include aga3:Grundkoder3/c2p1x1_blit_data.asm include aga3:grundkoder3/HAM8-screen_data.asm include aga3:grundkoder3/HAM8-chunky.data.asm section p1,data pattern_def incbin hd5:gfx/Env/HAM8/stone2128*128.ham8 section p2,data pattern_floor incbin hd5:gfx/Env/HAM8/marble128*128.ham8 section p3,data pattern_floor2 incbin hd5:Gfx/env/ham8/mois128*128.ham8 section p3,data pattern_roof incbin hd5:gfx/Env/HAM8/leather128*128.ham8 section p3,data pattern_roof2 incbin hd5:gfx/Env/HAM8/paper128*128.ham8 section p3,data pattern_wall2 incbin hd5:gfx/Env/HAM8/bricks128*128.ham8 section p3,data pattern_endwall incbin hd5:gfx/Env/HAM8/klas128*128.ham8