taylorza

Untitled

Jul 17th, 2022 (edited)
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         SLDOPT COMMENT WPMEM, LOGPOINT, ASSERTION
  2.         DEVICE ZXSPECTRUM48
  3.         CSPECTMAP "wifiprn.map"
  4.  
  5.         org  $8000
  6. header:        
  7. ;------------------------------------------------------------------------------
  8. ; Driver header
  9.         db "NDRV"               ; .DRV Signature
  10.         db "P"                  ; Driver ID - "P" standard printer device
  11.         db relocate_count       ; Number of relocations
  12.         db 0                    ; Number of 8K DivMMC RAM banks needed
  13.         db 0                    ; Number of 8K Spectrum RAM banks needed
  14.        
  15.         disp $0000              ; Driver entry point starts at $0000
  16.         RELOCATE_START HIGH
  17. ;------------------------------------------------------------------------------
  18. ; Driver code
  19. entry:
  20.         ld a, b
  21.        
  22.         cp $fb                  ; Output character
  23.         jp z, output_char       ; Use jp so that we get relocation generated
  24.  
  25.         cp $7f                  ; Get device status
  26.         jp z, get_status        ; Use jp so that we get relocation generated
  27.  
  28. .error
  29.         xor a                   ; A=0 unsupported call id
  30.         scf                     ; CY=1 indicates and error
  31.         ret
  32.  
  33. ;-----------------------------------------------------------------------------
  34. ; Call ID - $fb
  35. ; output_char
  36. ;       E - char to print
  37. output_char:
  38.         ld a, e                 ; Get char to print
  39.         and %00000111           ; Mask the lower bits to us as a border color
  40.         out ($fe), a            ; Write the border color
  41.  
  42.         or a                    ; Clear the carry flag to indicate no error
  43.         ret
  44.  
  45. ;------------------------------------------------------------------------------
  46. ; Call ID - $7f
  47. ; get_status
  48. get_status:    
  49.         ld bc, $133b            
  50.         or a                    ; Clear the carry flag to indicate success
  51.         in a, (c)               ; Read the UART status
  52.         bit 1, a                ; Test the TX Busy flag
  53.         ld bc, $ffff            ; Assume not busy
  54.         ret z                  
  55.         inc bc                  ; Printer is not ready
  56.         ret
  57.        
  58.         RELOCATE_END
  59.  
  60. ; Pad driver to 512
  61.         ASSERT $ <= 512, Driver image exceeds 512 bytes
  62.         ds 512-$, 0
  63.  
  64. ;------------------------------------------------------------------------------
  65. ; Relocation table placed after driver image
  66. relocator_table:
  67.         RELOCATE_TABLE
  68.                
  69. ;------------------------------------------------------------------------------
  70. ; Output configuration
  71. image_size       EQU     $$$-header ; Size includes the header, code and relocation table
  72.  
  73.         SAVEBIN "wifiprn.drv", $8000, image_size
Add Comment
Please, Sign In to add comment