Upon program startup 2 threads are started.
Thread 0 is used for updating the memory location while navigating through memory (up/down=page up/down, left/right=line up/down)
Thread 1 is where the action is. It takes the current memory location and dumps memory to the screen.
The screen is constantly updated, so you'r kinda watching "realtime".
Here's the cartridge binary:
memview.zip 2.84K
2 downloadsHere's the source code:
Spoiler
********@*****@*********************@**************************
AORG >6000
*--------------------------------------------------------------
* Cartridge header
*--------------------------------------------------------------
GRMHDR BYTE >AA,1,1,0,0,0
DATA PROG0
BYTE 0,0,0,0,0,0,0,0
PROG0 DATA 0 ; No more items following
DATA RUNLIB
MSG0 BYTE 13
TEXT 'MEMORY VIEWER'
*--------------------------------------------------------------
* Include required files
*--------------------------------------------------------------
COPY "D:\Projekte\spectra2\tms9900\runlib.a99"
*--------------------------------------------------------------
* SPECTRA2 startup options
*--------------------------------------------------------------
SPVMOD EQU GRAPH1 ; Video mode. See VIDTAB for details.
SPFONT EQU FNOPT3 ; Font to load. See LDFONT for details.
SPFCLR EQU >C0 ; Foreground/Background color for font.
SPFBCK EQU >01 ; Screen background color.
*--------------------------------------------------------------
* Variables
*--------------------------------------------------------------
TIMERS EQU >8342 ; Address of timer table (8 bytes). Space for future slots reserved
MEMORY EQU >8350 ; Current memory location
MEMOLD EQU >8352 ; Backup memory location
RAMBUF EQU >8354 ; Work buffer
***************************************************************
* Main
********@*****@*********************@**************************
MAIN BL @SETUP ; Setup screen
JMP SETUP2 ; Start memory viewer
***************************************************************
* GENERAL SETUP -- GENERAL SETUP -- GENERAL SETUP
***************************************************************
* SETUP ..:
***************************************************************
* SETUP - Set up CPU memory and VRAM
********@*****@*********************@**************************
SETUP MOV R11,R3 ; Save R11
BL @SCROFF ; Turn off screen
BL @CPYV2M
DATA >0980,RAMBUF,10*8 ; Copy patterns of digit 0-9 from VRAM to RAM
BL @CPYV2M
DATA >0A08,RAMBUF+80,6*8 ; Copy patterns of letters A-F from VRAM to RAM
BL @CPYM2V
DATA >0800,RAMBUF,16*8 ; Copy patterns of 0-9,A-F to VRAM => set 1
BL @CPYM2V
DATA >0880,RAMBUF,16*8 ; Copy patterns of 0-9,A-F to VRAM => set 2
BL @CPYM2V
DATA >0F80,RAMBUF,16*8 ; Copy patterns of 0-9,A-F to VRAM => set 16
BL @CPYM2V
DATA >0380,COLTAB,32 ; Load color table
BL @FILV
DATA >0000,32,32*24 ; Clear screen
MOV @START,@MEMORY
BL @SCRON ; Turn on screen
B *R3 ; Return
*--------------------------------------------------------------
* Some data used by subroutine
*--------------------------------------------------------------
COLTAB BYTE >C0,>C0,>F0,>F0,>50,>50,>50,>50,>50,>50,>50,>50,>50,>50,>50,>50
BYTE >50,>50,>F0,>F0,>C0,>C0,>C0,>C0,>C0,>C0,>C0,>C0,>C0,>C0,>04,>04
T3 BYTE 8,>F0,>F1,>F2,>F3,>F4,>F5,>F6,>F7
START DATA >6000 ; Starting position
* :..
***************************************************************
* MEMORY VIEWER -- MEMORY VIEWER -- MEMORY VIEWER
***************************************************************
* SETUP2 ..:
***************************************************************
* SETUP2 - Setup for memory viewer
********@*****@*********************@**************************
SETUP2 BL @PUTAT
DATA >0018,T3 ; Display 0..7 at Y=0 and X=24
LI R0,TIMERS
MOV R0,@WTITAB
LI R10,>0100 ; Set highest slot in use
BL @MKSLOT
DATA >0003,NAVI ; Start navigator task
DATA >0103,DUMP,EOL ; Start memory dump task
B @TMGR ; Run kernel task
* :..
* NAVI ..:
***************************************************************
* NAVI - Navigate through memory
********@*****@*********************@**************************
NAVI DECT STACK
MOV R11,*STACK ; Save R11
LI TMP1,22*8
MOV @WVRTKB,TMP0 ; Get keyboard flags
COC @KEY1,TMP0
JEQ NAVIA
COC @KEY2,TMP0
JEQ NAVIB
LI TMP1,8
COC @KEY3,TMP0
JEQ NAVIA
COC @KEY4,TMP0
JEQ NAVIB
JMP NAVIZ
NAVIA S TMP1,@MEMORY
JMP NAVIZ
NAVIB A TMP1,@MEMORY
NAVIZ B @POPRT ; Exit
KEY1 DATA K1UP ; Up
KEY2 DATA K1DN ; Down
KEY3 DATA K1LF ; Left
KEY4 DATA K1RG ; Right
* :..
* DUMP ..:
***************************************************************
* DUMP - Take CPU memory dump
********@*****@*********************@**************************
DUMP DECT STACK
MOV R11,*STACK ; Save R11
MOV @MEMORY,@MEMOLD ; Take copy
LI R2,23 ; 23 rows
*--------------------------------------------------------------
* Do initialisation
*--------------------------------------------------------------
MOV @MEMORY,R0
BL @PUTHEX ; Display current memory address
DATA >0013,MEMORY,RAMBUF,16
MOV @ZTMP00,@WYX ; Set cursor start position
*--------------------------------------------------------------
* Display byte values
*--------------------------------------------------------------
DUMP1 LI R1,4 ; 4 Columns
ORI CONFIG,>8000 ; Set display bit
BL @MKHEX
DATA MEMORY,RAMBUF,>F0
AB @BD4,@BX ; Next column
DUMP2 MOV @MEMORY,R0
MOV *R0,R0 ; Display address
ORI CONFIG,>C000 ; Set bit 0-1 (display bit, next charset bit)
BL @MKHEX
DATA R0HB,RAMBUF,0 ; Dump word
AB @BD5,@BX
INCT @MEMORY ; Next word
DEC R1
JNE DUMP2
*--------------------------------------------------------------
* Display bytes as string
*--------------------------------------------------------------
LI R1,8 ; Bytes to process
MOV @MEMORY,R0
S R1,R0
LI TMP1,RAMBUF
MOVB @BD8,*TMP1+ ; Set string length
DUMP3 MOVB *R0+,TMP2
SRL TMP2,8
CI TMP2,33
JLT DUMP4
CI TMP2,127
JGT DUMP4
SWPB TMP2
JMP DUMP5
DUMP4 LI TMP2,>2E00 ; Display '.' character
DUMP5 MOVB TMP2,*TMP1+ ; Write byte
DEC R1 ;
JNE DUMP3 ; Repeat until all bytes processed
BL @PUTSTR ; Display string
DATA RAMBUF
*--------------------------------------------------------------
* Update position counters
*--------------------------------------------------------------
AB @BD1,@BY ; Next row
MOVB @BD0,@BX ; Start with column
DEC R2
JNE DUMP1
MOV @MEMOLD,@MEMORY ; Restore current memory address
DUMPZ B @POPRT ; Exit
*--------------------------------------------------------------
* Some data used by subroutine
*--------------------------------------------------------------
ZTMP00 DATA >0100 ; Display position Y=2, X=0
* :..
END














