home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / enterprs / c128 / util / sfxsrc.arc / PORTABLE.A < prev    next >
Encoding:
Text File  |  1990-02-12  |  4.3 KB  |  213 lines

  1. ; portable.a
  2. ;─────────────────────────────────────────────────────────────────────────────
  3. ; LHARC self extract code - Machine specific routines for C64 or C128
  4. ;─────────────────────────────────────────────────────────────────────────────
  5.  
  6.             INSTXT "sfx.i"
  7.  
  8.             PUBLIC Portable
  9.             PUBLIC Prt
  10.             PUBLIC Romin
  11.             PUBLIC Romout
  12.             PUBLIC Basic
  13.  
  14. la          EQU $00b8
  15. sa          EQU $00b9
  16. dv          EQU $00ba
  17. fnadr       EQU $00bb
  18. fnlen       EQU $00b7
  19. fnbank      EQU $00c7
  20.  
  21. Portable    lda $ff00               ; Test for C64 or C128
  22.             tax
  23.             eor #$80
  24.             sta $ff00
  25.             cpx $ff00
  26.             beq Adorable64          ; 64
  27.             ldy #Jmp128-JmpOrg
  28.             fcb $2c
  29. Adorable64  ldy #Jmp64-JmpOrg       ; Fill in jumptable apropriately
  30.             ldx #0
  31. JumpLoop    lda JmpOrg,y
  32.             sta JmpOrg,x
  33.             iny
  34.             inx
  35.             cpx #Jmp128-Jmp64
  36.             bcc JumpLoop
  37.             lda #0                  ; Black border and background
  38.             sta $d020
  39.             sta $d021
  40.             rts
  41.  
  42. JmpOrg
  43.  
  44. Prt         fcb 0,0,0
  45. Romin       fcb 0,0,0
  46. Romout      fcb 0,0,0
  47. Basic       fcb 0,0,0
  48.  
  49. Jmp64       jmp Prt64
  50.             jmp Romin64
  51.             jmp Romout64
  52.             jmp $a474
  53.  
  54. Jmp128      jmp Prt128
  55.             jmp Romin128
  56.             jmp Romout128
  57.             jmp GoBasic128
  58.  
  59. JmpEnd
  60.  
  61. ;────────────────────────────────────────────────
  62. ; Exit the program. Go back to BASIC interpreter
  63. ;────────────────────────────────────────────────
  64. ; C128 can't just JMP there because we may be
  65. ; running underneath the BASIC ROMs
  66.  
  67. GoBasic128  ldy #8
  68. Gblp        lda JmpBasic,y
  69.             sta $0b00,y
  70.             dey
  71.             bpl Gblp
  72.             jmp $0b00
  73.  
  74. JmpBasic    lda #0
  75.             sta $ff00
  76.             jmp $4003
  77.  
  78.  
  79. ;─────────────────────────────────────────────
  80. ; RomIn  enables the system ROMs,
  81. ; RomOut switches to an all RAM configuration
  82. ;─────────────────────────────────────────────
  83.  
  84. Romin64     php
  85.             pha
  86.             lda #7
  87.             sta 1
  88.             pla
  89.             plp
  90.             cli
  91.             rts
  92.  
  93. Prt64       jsr Romin64
  94.             jsr $e716
  95. Romout64    sei
  96.             php
  97.             pha
  98.             lda #0
  99.             sta 1
  100.             pla
  101.             plp
  102.             rts
  103.  
  104. Romin128    php
  105.             pha
  106.             lda #%00001110
  107.             sta $ff00
  108.             pla
  109.             plp
  110.             rts
  111.  
  112. Prt128      jsr Romin128
  113.             jsr $c00c
  114. Romout128   sta $ff01
  115.             rts
  116.  
  117.  
  118.  
  119.             PUBLIC stop
  120.             PUBLIC open
  121.             PUBLIC close
  122.             PUBLIC chrout
  123.             PUBLIC chkout
  124.             PUBLIC clrchn
  125.             PUBLIC setnam
  126.             PUBLIC setlfs
  127.             PUBLIC chrin
  128.             PUBLIC getin
  129.  
  130.             PUBLIC Message
  131.  
  132. Message     stx T10
  133.             sty T10+1
  134.             ldy #0
  135. Loop        lda (T10),y
  136.             beq MssgX
  137.             jsr Prt
  138.             iny
  139.             bne Loop
  140. MssgX       rts
  141.  
  142.  
  143. stop        jsr Romin
  144.             jsr $ffe1
  145.             jmp Romout
  146.  
  147. getin       jsr Romin
  148.             jsr $ffe4
  149.             jmp Romout
  150.  
  151. open        jsr Romin
  152.             jsr $ffc0
  153.             jmp Romout
  154.  
  155. close       jsr Romin
  156.             jsr $ffc3
  157.             jmp Romout
  158.  
  159. chrout      jsr Romin
  160.             jsr $ffd2
  161.             jmp Romout
  162.  
  163. chrin       jsr Romin
  164.             jsr $ffcf
  165.             jmp Romout
  166.  
  167. chkout      jsr Romin
  168.             jsr $ffc9
  169.             jmp Romout
  170.  
  171. clrchn      jsr Romin
  172.             jsr $ffcc
  173.             jmp Romout
  174.  
  175. setnam      sta fnlen
  176.             stx fnadr
  177.             sty fnadr+1
  178.             pha
  179.             lda #0
  180.             sta fnbank              ; Does nothing except clear RVS on C64
  181.             pla
  182.             rts
  183.  
  184. setlfs      sta la
  185.             stx dv
  186.             sty sa
  187.             rts
  188.  
  189. ;──────────────────────────
  190. ; Convert ascii to Petscii
  191. ;──────────────────────────
  192.  
  193.             PUBLIC a2p
  194.  
  195. a2p         cmp #$41
  196.             bcc a2px
  197.             cmp #$5b
  198.             bcs a2p2
  199.             ora #$80
  200. a2px        rts
  201.  
  202. a2p2        cmp #$61
  203.             bcc a2px
  204.             cmp #$7b
  205.             bcs a2px
  206.             and #$df
  207.             rts
  208.  
  209.             END
  210.  
  211.  
  212.  
  213.