Advertisement
Zeda

tok2chars

Aug 6th, 2015
558
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. _GetTokStrng = 4594h
  2. _CreateTempString=4324h
  3. _OP4ToOP1=4138h
  4. _StoAns=4ABFh
  5. ;EFD74AD604C02AEC86772C772CEB4E234623
  6. ;E5C5D5EF9445218E84D1CDD89D2AEC860922EC86C1E1EDA1EAA79D
  7. ;2AEC86E5EF2443E1131321EE86EDB0EF3841EFBF4AC9
  8. ;010000
  9. ;03F57E23
  10. ;FE2020043E291829
  11. ;FE2820043E101821
  12. ;D641FE1B3004C6411817
  13. ;D620FE1A3804C661180D
  14. ;13FE0D3FCEB0F5033EBB1213F1
  15. ;1213F13D20C6C9
  16.     bcall(_RclAns)
  17.     sub 4
  18.     ret nz
  19.     ld hl,(saveSScreen)
  20.     ld (hl),a
  21.     inc l
  22.     ld (hl),a
  23.     inc l
  24.     ex de,hl
  25.     ld c,(hl)
  26.     inc hl
  27.     ld b,(hl)
  28.     inc hl
  29. detokloop:
  30.     push hl     ;points to instr
  31.     push bc     ;size of instr
  32.     push de     ;points to outstr
  33.     bcall(_GetTokStrng)
  34.     ld hl,OP3
  35.     pop de
  36.     call ASCIIToTok
  37.     ld hl,(saveSScreen)
  38.     add hl,bc
  39.     ld (saveSScreen),hl
  40.     pop de
  41.     ld hl,OP3
  42.     ldir
  43.     pop bc
  44.     pop hl
  45.     cpi
  46.     jp pe,detokloop
  47. ;;now make the new string
  48.     ld hl,(saveSScreen)
  49.     push hl
  50.     bcall(_CreateTempString)
  51.     pop hl
  52.     inc de
  53.     inc de
  54.     ld hl,saveSScreen+2
  55.     ldir
  56.     bcall(_OP4ToOP1)
  57.     bcall(_StoAns)
  58.     ret
  59. ASCIIToTok:
  60. ;;HL points to ASCII string
  61. ;;A is the size
  62. ;;DE is where to write
  63. ;;Out: DE updated, BC is the new size
  64.     ld bc,0
  65. loop:
  66.     inc bc
  67.     push af
  68.     ld a,(hl)
  69.     inc hl
  70.     cp 20h \ jr nz,$+6 \ ld a,29h \ jr tokout
  71.     cp 28h \ jr nz,$+6 \ ld a,10h \ jr tokout
  72.     sub 41h
  73.     cp 27 \ jr nc,$+6 \ add a,41h \ jr tokout
  74.     sub 20h
  75.     cp 26 \ jr c,$+6 \ add a,61h \ jr tokout
  76.     inc de
  77.     cp 13
  78.     ccf
  79.     adc a,$B0
  80.     push af
  81.     inc bc
  82.     ld a,$BB
  83.     ld (de),a
  84.     inc de
  85.     pop af
  86. tokout:
  87.     ld (de),a
  88.     inc de
  89.     pop af
  90.     dec a
  91.     jr nz,loop
  92.     ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement