home *** CD-ROM | disk | FTP | other *** search
/ ticalc.org / ticalc_org_rev_b.iso / archives / 85 / asm / source / zshell / romdump.asm < prev    next >
Encoding:
Assembly Source File  |  2001-07-01  |  9.6 KB  |  362 lines

  1. ;ROM dump version 1.0b2
  2. ;last updated:1/6/98 at 23:27 hours(11:27pm)
  3. ;This utility will let you dump a 16K block of ROM.  Address are from $0000-$3FFF, and
  4. ;$4000-$7FFF, pages 0-7.  
  5. ;Anyway, this is for ZShell and this is a Beta 2 release
  6. ;It is very well commented and if you have any questions e-mail me
  7. ;
  8. ;Matt Butch
  9. ;mjb25@hotmail.com
  10. ;
  11. ;PS:This file is written for CAZ on the Mac.
  12.  
  13. INCLUDE "TI-85.H"
  14.  
  15. ORG 0
  16. DEFM "ROM  Dump v1.0 B2", 0
  17. CALL ROM_CALL
  18. DEFB CLEARLCD;          what do you think?
  19. LD HL, ZS_BITS;   tell zshell(or whatever) to recalc checksum
  20. SET 0, (HL)
  21. LD BC, #0100;     display title screen
  22. LD DE, TITLE
  23. SET 3, (IY+05);         set inverted text
  24. CALL CALL_
  25. DEFW DISPLAY;       call my special and easy to use display routine-see attached files
  26. RES 3, (IY+05);        set back normal text
  27. LD BC, #0402
  28. LD DE, DIVNM
  29. CALL CALL_
  30. DEFW DISPLAY
  31. RPT:;                               wait
  32.   CALL GET_KEY
  33.   CP 00
  34.   JR Z, RPT
  35. START:
  36. CALL ROM_CALL
  37. DEFB CLEARLCD
  38. LD A, 7;                  select mem page
  39. OUT (5), A;            and output it
  40. LD A, (#7FFF);       load rom ver.(it's  not #8C8E-"ROM_VER" because TinyPhat, and some other
  41. ;                                                            OS's didn't have this, and romdump would crash) 
  42. CP 57;                   start of compares of ROM versions, this is 3.0A
  43. JR NZ, NXTROM1
  44. LD C, 00;             load offset of table of ASCII strings of ROM ver ("3.0A")
  45. LD DE, #29A1;   load ROM call of variable allocation(thanks to Dines for TI-ROMadd.txt)
  46. NXTROM1:
  47.   CP 8E;              4.0
  48.   JR NZ, NXTROM3
  49.   LD C, #05
  50.   LD DE, #29A5
  51. NXTROM3:
  52.   CP 5E;            5.0
  53.   JR NZ, NXTROM4
  54.   LD C, #09
  55.   LD DE, #29A5
  56. NXTROM4:
  57.   CP 3D;             6.0
  58.   JR NZ, NXTROM5
  59.   LD C, #0D
  60.   LD DE, #29A5
  61. NXTROM5:
  62.   CP 97;            8.0
  63.   JR NZ, NXTROM6
  64.   LD C, #11
  65.   LD DE, #29A9
  66. NXTROM6:
  67.   CP #91;        9.0
  68.   JR NZ, NXTROM7
  69.   LD C, #15
  70.   LD DE, #2954
  71. JR LOAD_NO
  72. NXTROM7:
  73. CP 35;           10.0
  74. CALL JUMP_NZ;        if a wrong ROM ver is found (the only other ROM ver is 2.0)
  75. DEFW  ERROR1;         goto error subroutine 1
  76. LD C, #1A
  77. LD DE, #296E
  78. LOAD_NO:
  79. PUSH BC
  80. PUSH DE
  81. LD HL, (PROGRAM_ADDR)
  82. LD DE, VATALLRC
  83. ADD HL, DE;  get location of call location
  84. INC HL;    skip over call instruction(#CD) and to the area where the value to be called is
  85. POP DE
  86. LD (HL), E ;   load it
  87. INC HL
  88. LD (HL), D
  89. POP BC
  90. LD B, 00
  91. LD HL, ROMVERTAB
  92. ADD HL, BC
  93. LD DE, (PROGRAM_ADDR)
  94. ADD HL, DE;        point to ASCII equivalent of ROM version
  95. LD BC, #0C00
  96. LD (CURSOR_ROW), BC
  97. CALL ROM_CALL
  98. DEFB D_ZT_STR ; display it
  99. LD BC, 0200
  100. LD DE, ROMVER
  101. CALL CALL_
  102. DEFW DISPLAY
  103. LD HL, (X8BEB);       load last byte of free memory
  104. LD DE, (#8BE1);      load first byte of free memory
  105. SCF;                           set carry flag
  106. CCF;                          complement carry flag-here I use it to reset the CY flag
  107. SBC HL, DE;              subtract them
  108. LD DE, #4000;           load size of string that the dump will be put in
  109. SCF
  110. CCF
  111. SBC HL, DE;  here it is used to compare the size of free memory and the size of the ROM dump
  112. CALL JUMP_NC;     if DE is greater than HL than goto error subroutine 2  
  113. DEFW ERROR2
  114. LD BC, 0000;    display menu
  115. LD DE, ROMVER
  116. CALL CALL_
  117. DEFW DISPLAY
  118. LD BC, #0002
  119. LD DE, CHOOSE
  120. CALL CALL_
  121. DEFW DISPLAY
  122. LD BC, #0003
  123. LD DE, F1MENU
  124. CALL CALL_
  125. DEFW DISPLAY
  126. LD BC, #0004
  127. LD DE, F1ADDR
  128. CALL CALL_
  129. DEFW DISPLAY
  130. LD BC, #0005
  131. LD DE, F2MENU
  132. CALL CALL_
  133. DEFW DISPLAY
  134. LD BC, #0006
  135. LD DE, F2ADDR
  136. CALL CALL_
  137. DEFW DISPLAY
  138. LD BC, #0007
  139. LD DE, F5MENU
  140. CALL CALL_
  141. DEFW DISPLAY
  142. KEY:
  143.   CALL GET_KEY
  144.   CP 00
  145.   JR Z, KEY
  146.   CP K_F1
  147.   JR Z, LWRROM
  148.   CP K_F2
  149.   JR Z, UPRROM
  150.   CP K_F5
  151.   RET Z
  152.   CP K_EXIT
  153.   RET Z
  154.   JR KEY
  155. LWRROM:
  156.   LD DE, LRVATN;  point DE to the VAT name
  157.   LD HL, (PROGRAM_ADDR)
  158.   ADD HL, DE;  HL now points to the VAT name in RAM 
  159.   LD DE, #0000;   point to the start of the dump in ROM
  160.   CALL JUMP_;            jump to the dumping routine
  161.   DEFW PRESTART
  162. UPRROM:
  163.   LD A, #00;      the following lines clear everything off the screen except the ROM version 
  164.   LD (VIDEO_MEM+#80), A
  165.   LD HL, VIDEO_MEM+#80
  166.   LD DE, VIDEO_MEM+#81
  167.   LD BC, #37F
  168.   LDIR
  169.   LD BC, #0002;        display the "Enter Mem page" screen
  170.   LD DE, URSTR
  171.   CALL CALL_
  172.  DEFW DISPLAY
  173.   LD BC, #0003
  174.   LD DE, CHPAGE
  175.   CALL CALL_
  176. DEFW DISPLAY
  177.   LD B, 0
  178. WAIT:
  179.   CALL GET_KEY
  180.   CP 00
  181.   JR Z, WAIT
  182.   CP K_EXIT
  183.   CALL JUMP_Z
  184.   DEFW START
  185.   CP K_ENTER
  186.   JR Z, CONT
  187.  ;                this starts my ingenius routine that converts keycodes to ASCII, with a very small 
  188. ;                 table (only 10 bytes)
  189.   CP #12;   elimanates keys under #12, but not #12, which is 3
  190.   JR C, WAIT
  191.   CP #25;   elimanates keys over #25
  192.   JR NC, WAIT
  193.   SUB #12;   if the key is 3, the value in A is 0, 6 is 1, and 9 is 2, 2-8, 5-9, 8-A, 0-F, 1-10, 4-11,7-12  
  194.   CP 3
  195.   JR C, D_NMBR;  if it is less than 3 goto the display routine
  196.   SUB 3;  now if the key is 2, A is 5, 5-6, 8-7, 0-C, 1-D, 4-11, 7-12
  197.   CP 5;  get rid of all keys less than 1A(original keycode)
  198.   JR C, WAIT
  199.   SUB 5;  key-2, A-0, 5-1, 8-2, 0-7, 1-8, 4-9, 7-A
  200.   CP 3;      if it is under 3, goto the predisplay routine
  201.   JR C, GOADD3
  202.   CP 7;    under 7(which is 0, here) is thrown back to the key get routine
  203.   JR C, WAIT
  204.   SUB 7;  0 is 0, 1-1, 4-2, 7-3
  205.   CP #04; under 4, valid key goto a second predisplay routine
  206.   JR C, GOADD6
  207.   JR WAIT;  otherwise go back to the key get routine
  208. GOADD3:
  209.   ADD A, 3;  this adds 3 to the middle set of keys to set the offset right: 2 is 3, 5 is 4, 8 is 5
  210.   JR D_NMBR; goto display routine
  211. GOADD6:
  212.   ADD A, 6; this adds 6 to the left set of keys to set the offset right:0 is 6, 1 is 7, 4 is 8, 7 is 9
  213. D_NMBR:
  214.   CP 2;  if A is 2, which is 9, go back to the key get routine-this is because there is no mem page 9
  215.   JR Z, WAIT
  216.   CP 5;              same as above, but this is for key 8
  217.   JR Z, WAIT
  218.   LD HL, (PROGRAM_ADDR)
  219.   LD DE, NMBR_TAB
  220.   ADD HL, DE;                        point HL to the table of ASCII values
  221.   LD D, 00
  222.   LD E, A
  223.   ADD HL, DE;                         HL now points to the correct ASCII value
  224.   LD A, (HL)
  225.   LD (TEXT_MEM), A;                    save the ASCII value for later use
  226.   LD BC, #1203
  227.   LD (CURSOR_ROW), BC
  228.   CALL ROM_CALL
  229.   DEFB TX_CHARPUT;             display it
  230.   CALL JUMP_
  231.   DEFW WAIT
  232. CONT:
  233. LD DE, URVATN
  234. LD HL, (PROGRAM_ADDR)
  235. ADD HL, DE;                             HL now points to the VAT name
  236. PUSH HL
  237. LD DE, 0009
  238. ADD HL, DE
  239. LD A, (TEXT_MEM) ;           get the saved value of the ROM page choice
  240. LD (HL), A;                            put it in the VAT name        
  241. POP HL
  242. SUB #30;                              convert to a actual value
  243. OUT (5), A;                          set the mem page
  244. LD DE, #4000;                    point to the start of the dump
  245. PRESTART:
  246. PUSH DE
  247. RST #20;                           move the VAT name into OP1
  248. LD HL, #4002;            this is the size of the string to allocate, #4000 for the dump, 2 for the size
  249. LD A, #0C;                   type code
  250. VATALLRC:
  251. CALL X2954;               this is the routine to allocate the string
  252. EX DE, HL;                   HL now points to the  data area where the string is at
  253. LD BC, #0040
  254. LD (HL), B
  255. INC HL
  256. LD (HL), C ;            load the size into the 2 bytes before the actual string
  257. EX DE, HL;              DE now points to the data entry
  258. INC DE;                    this is needed because DE points to 1 byte before the actual entry
  259. POP HL;                   HL now points to the source
  260. LD BC, #4000       # of bytes to copy
  261. LDIR;                        copy it
  262. CALL ROM_CALL
  263. DEFB CLEARLCD
  264. LD BC, #0000
  265. LD DE, DONE
  266. CALL CALL_
  267. DEFW DISPLAY
  268. HOLD:
  269.   CALL GET_KEY
  270.   CP 00
  271.   JR Z, HOLD
  272.   RET
  273.  
  274.  
  275. ;Error subroutines
  276.  
  277. ERROR1:
  278. CALL ROM_CALL
  279. DEFB CLEARLCD
  280. LD BC, #0000
  281. LD DE, ERRORSTR1A
  282. CALL CALL_
  283. DEFW DISPLAY
  284. LD BC, #0002
  285. LD DE, ERRORSTR1B
  286. CALL CALL_
  287. DEFW DISPLAY
  288. LD BC, #0003
  289. LD DE, ERRORSTR1C
  290. CALL CALL_
  291. DEFW DISPLAY
  292. LD BC, #0004
  293. LD DE, ERRORSTR1D
  294. CALL CALL_
  295. DEFW DISPLAY
  296. JP PAQ
  297. ERROR2:
  298. CALL ROM_CALL
  299. DEFB CLEARLCD
  300. LD BC, #0000
  301. LD DE, ERRORSTR2A
  302. CALL CALL_
  303. DEFW DISPLAY
  304. LD BC, #0002
  305. LD DE, ERRORSTR2B
  306. CALL CALL_
  307. DEFW DISPLAY
  308. LD BC, #0003
  309. LD DE, ERRORSTR2C
  310. CALL CALL_
  311. DEFW DISPLAY
  312. PAQ:
  313.   CALL GET_KEY
  314.   CP K_ENTER
  315.   JR NZ, PAQ
  316.   RET
  317.  
  318. ;DISPLAY Subroutine
  319. ;This routine I designed makes makes it so much easier to display strings
  320. ;Input:
  321. ;BC-XXYY:XX-Column, YY-Row
  322. ;DE-String to display
  323.  
  324. DISPLAY:
  325. LD (#800C), BC;                              load cursor values into the proper memory area
  326. LD HL, (PROGRAM_ADDR);           load the program address
  327. ADD HL, DE;                                     add the offset and the ProgAddr to get the mem addr
  328. CALL ROM_CALL
  329. DEFB D_ZT_STR;                             display it.  This can be changed to D_ZM_STR, etc.
  330. RET
  331.  
  332.  
  333. TITLE: DEFM "ROM Dump  ver 1.0B2", 0
  334. DIVNM: DEFM "by Matt Butch", 0
  335. CHOOSE: DEFM "Choose ROM location", 0
  336. F1MENU: DEFM "F1:Lower 16K ROM", 0
  337. F1ADDR: DEFM "$0000-$3FFF", 0
  338. F2MENU: DEFM "F2:Upper 16K ROM", 0
  339. F2ADDR: DEFM "$4000-$7FFF w/8 pages", 0
  340. F5MENU: DEFM "F5:Quit", 0
  341. URSTR: DEFM "Upper ROM:$4000-$7FFF", 0
  342. CHPAGE: DEFM "Enter memory page:", 0
  343. ROMVER: DEFM "ROM version:", 0
  344. ERRORSTR1A: DEFM "ERROR 1:ROM VER ERROR", 0
  345. ERRORSTR1B: DEFM "Unable to recognise", 0
  346. ERRORSTR1C: DEFM "ROM ver.  Need ROM ver", 0
  347. ERRORSTR1D: DEFM "3.0A-10.0", 0
  348. ERRORSTR2A: DEFM "ERROR 2:MEM NOT AVAIL", 0
  349. ERRORSTR2B: DEFM "Unable to allocate", 0
  350. ERRORSTR2C: DEFM "necessary 16KB of RAM", 0
  351. ROMVERTAB: DEFM  "3.0A", 0, "4.0", 0, "5.0", 0, "6.0", 0, "8.0", 0, "9.0", 0, "10.0", 0
  352. NMBR_TAB: DEFM "3692580147"
  353. LRVATN:
  354. DEFB 00, 06
  355. DEFM "LWRROM"
  356. URVATN: 
  357. DEFB 00, 08
  358. DEFM "UPRROMPX"
  359. DONE: DEFM "ROM dump complete", 0
  360.  
  361. END
  362.