home *** CD-ROM | disk | FTP | other *** search
/ ticalc.org / ticalc_org_rev_b.iso / archives / 82 / asm / source / crash / ld2train.asm < prev    next >
Encoding:
Assembly Source File  |  2001-07-01  |  5.1 KB  |  250 lines

  1. ;────────────────────────────────────────────────────────────────────────────
  2. ;
  3. ; PROGRAM: Little Dude 2 trainer
  4. ; VERSION: 1.10
  5. ; AUTHOR:  David Eriksson <david@2goodsoft.com>
  6. ; WEB:     http://www.2goodsoft.com/
  7. ; DATE:    05/07/98
  8. ;
  9. ; Provides cheating by certain key presses.
  10. ;
  11. ; THIS SOFTWARE IS NOT SUPPORTED BY THE AUTHOR OF LITTLE DUDE 2
  12. ;
  13. ; The author of LD2, Chris Edwards <cxe162@psu.edu>, has informed me that
  14. ; I should tell you this, and he also says that it will NOT work on his 
  15. ; next game :)
  16. ;
  17. ; To find out the right memory locations and to test the trainer during
  18. ; development I used CalcEm - The Calculator Emulator.
  19. ;        http://www.2goodsoft.com/calcem/
  20. ; (In fact, this has not yet been tested on a calculator!)
  21. ;
  22. ; The interrupt stuff is an almost exact rip of Crash to CrASH v1.3
  23. ;
  24. ;────────────────────────────────────────────────────────────────────────────
  25.  
  26. .NOLIST
  27. #INCLUDE "crash82.inc"
  28. .LIST
  29.  
  30. .DB "CalcEm Little Dude 2 Trainer",0
  31.  
  32. INT_LD2TRAIN    .EQU    0d2h    ; I have no registered ID byte :-(((
  33.  
  34. ;────────────────────────────────────────────────────────────────────────────
  35. ; Main
  36. ;────────────────────────────────────────────────────────────────────────────
  37. Main:
  38.     call    CR_GRBCopy            ; Clear screen
  39.  
  40.     ld        bc, 0000h            ; (0, 0)
  41.     ld        (GRAF_CURS), bc
  42.  
  43.     SET        3, (IY+05)            ; Display inverted
  44.     ld        hl, szInfo1
  45.     ROM_CALL(D_ZM_STR)
  46.     RES        3, (IY+05)            ; Display normal
  47.  
  48.     ld        bc, 0804h            ; (4, 8)
  49.     ld        (GRAF_CURS), bc
  50.     ld        hl, szInfo2
  51.     call    DrawStringList
  52.  
  53.     ld        bc, 1C30h            ; (48, 28)
  54.     ld        (GRAF_CURS), bc
  55.     ld        hl, szInfo3
  56.     call    DrawStringList
  57.  
  58.     ld        bc, 3604h            ; (4, 54)
  59.     ld        (GRAF_CURS), bc
  60.  
  61.     ld        a, (INT_STATE)        ; Check out CrASH's interrupt byte
  62.     cp        INT_LD2TRAIN
  63.     jr        z, Remove
  64.     
  65.     or        a
  66.     jr        z, Install
  67.     
  68.     ld        hl, szAnother
  69.     ROM_CALL(D_ZM_STR)
  70.  
  71. WaitKey:                   ; After this, it will return to CrASH
  72.     jp        CR_KHAND
  73.  
  74. ;────────────────────────────────────────────────────────────────────────────
  75. ; Install interrupt
  76. ;────────────────────────────────────────────────────────────────────────────
  77. Install:
  78.     ld        hl, szInstall
  79.     ROM_CALL(D_ZM_STR)
  80.     
  81.     ld        hl, 8400h
  82.     ld        de, 8401h
  83.     ld        (hl), 83h
  84.     ld        bc, 100h
  85.     ldir
  86.     
  87.     ld        hl, IntProcStart
  88.     ld        de, 8383h
  89.     ld        bc, IntProcEnd-IntProcStart+1
  90.     ldir
  91.     
  92.     ld        hl, 15bh
  93.     ld        (APD_FREE), HL
  94.     
  95.     ld        a, 84h
  96.     ld        i, a
  97.     
  98.     im        2
  99.     
  100.     jr        WaitKey
  101.  
  102. ;────────────────────────────────────────────────────────────────────────────
  103. ; Remove interrupt
  104. ;────────────────────────────────────────────────────────────────────────────
  105. Remove:
  106.     ld        hl, szRemove
  107.     ROM_CALL(D_ZM_STR)
  108.     
  109.     im        1
  110.     
  111.     ld        hl, 300h
  112.     ld        (APD_FREE), hl
  113.     
  114.     xor        a
  115.     ld        i, a
  116.     ld        (INT_STATE), a
  117.         
  118.     jr        WaitKey
  119.  
  120. ;────────────────────────────────────────────────────────────────────────────
  121. ; DrawStringList
  122. ;
  123. ; Draws one string on each row until an empty string is reached
  124. ;
  125. ; Input: HL = string pointer
  126. ;────────────────────────────────────────────────────────────────────────────
  127. DrawStringList:
  128.     ld        a, (CURSOR_X)        ; Save X
  129.     ld        b, a
  130.  
  131. dsl_loop:
  132.     ROM_CALL(D_ZM_STR)            ; Draw string
  133.     
  134.     ld        a, (CURSOR_Y)        ; Advance Y
  135.     add        a, 6
  136.     ld        (CURSOR_Y), a
  137.     
  138.     ld        a, b                ; Restore X
  139.     ld        (CURSOR_X), a
  140.     
  141.     ld        a, (hl)                ; Check for empty string
  142.     or        a
  143.     jr        nz, dsl_loop
  144.     
  145.     ret
  146.  
  147.  
  148. ;────────────────────────────────────────────────────────────────────────────
  149. ; Interrupt proc
  150. ;────────────────────────────────────────────────────────────────────────────
  151. IntProcStart:
  152.     di
  153.     ex        af, af'
  154.     exx
  155.     
  156.     ; Set CrASH's interrupt byte
  157.     ld        a, INT_LD2TRAIN
  158.     ld        (INT_STATE), A
  159.     
  160.     ; Check 'location'
  161.     ld        a, (8121h)
  162.     cp        0ffh            ; Inside CrASH?
  163.     jr        nz, ExitInt
  164.         
  165.     ; Check keyboard
  166.     ld        a, 11111101b
  167.     out        (P_KEYBOARD), a
  168.     in        a, (P_KEYBOARD)
  169.     
  170.     cp        0ffh            ; Nothing? (most probable)
  171.     jr        z, ExitInt
  172.  
  173.     bit        4, a            ; Test / key
  174.     jr        z, Ammo
  175.  
  176.     bit        3, a            ; Test * key
  177.     jr        z, Health
  178.  
  179.     bit        2, a            ; Test - key
  180.     jr        z, Lives
  181.     
  182.     bit        1, a            ; Test + key
  183.     jr        z, Timer
  184.  
  185. ExitInt:
  186.     exx
  187.     ex        af, af'
  188.     jp        38h
  189.  
  190. ;
  191. ; We will be modifying inside TEXT_MEM so no one gets hurt...
  192. ;
  193. ; If these values were 255, the counter would wrap if you 
  194. ; pick up another item :-)
  195. ;
  196.  
  197. Lives:
  198.     ld        a, 063h
  199.     ld        (80cch), a        ; Lives
  200.     jr        ExitInt
  201.  
  202. Timer:
  203.     ld        a, 255
  204.     ld        (80d8h), a        ; Timer
  205.     jr        ExitInt
  206.  
  207. Health:
  208.     ld        a, 063h
  209.     ld        (80a7h), a        ; Health
  210.     jr        ExitInt
  211.  
  212. Ammo:
  213.     ld        a, 063h
  214.     ld        (80d1h), a        ; Shotgun
  215.     ld        (80d2h), a        ; Freeze ray
  216.     ld        (80d3h), a        ; Rocket launcher
  217.     ld        (80d4h), a        ; Grenades
  218.     jr        ExitInt
  219.  
  220. IntProcEnd:
  221.  
  222. ;────────────────────────────────────────────────────────────────────────────
  223. ; Static data
  224. ;────────────────────────────────────────────────────────────────────────────
  225. szInfo1:
  226. .DB        " (c) 2GooD Productions ", 12
  227. .DB        " v 1.10", 0
  228.  
  229. szInfo2:
  230. .DB        "This software is NOT", 0
  231. .DB        "supported by the author of",0
  232. .DB        "Little Dude 2!",0
  233. .DB        0
  234.  
  235. szInfo3:
  236. .DB        ' ',0c1h,"/]   Ammo",0
  237. .DB        0c1h,"*]  Health",0
  238. .DB        ' ',0c1h,"-]   Lives",0
  239. .DB        ' ',0c1h,"+]   Timer",0
  240. .DB        0
  241.  
  242. szInstall:
  243. .DB        "Installing...",0
  244.  
  245. szRemove:
  246. .DB        "Removing...",0
  247.  
  248. szAnother:    
  249. .DB        "Unable to install!",0
  250.