User Tools

Site Tools


system_interface

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
system_interface [2025/07/03 16:08] reggiesystem_interface [2025/08/26 15:57] (current) – [Keyboard] reggie
Line 5: Line 5:
   const SIbaseAddress=$ff80   const SIbaseAddress=$ff80
   const SIrefreshOff=0, SIrefreshOn=1, SIgraphicsMode=2, SIkeyInterface=3;   const SIrefreshOff=0, SIrefreshOn=1, SIgraphicsMode=2, SIkeyInterface=3;
 +  const SIArrowButtons=4;
  
   SIrefreshOff       Write <any> to force OFF register refresh and display animation   SIrefreshOff       Write <any> to force OFF register refresh and display animation
Line 10: Line 11:
   SIgraphicsMode     Write <number of colours> to select graphics mode (2, 4, 16 allowed values)   SIgraphicsMode     Write <number of colours> to select graphics mode (2, 4, 16 allowed values)
   SIkeyInterface     Write 0 then read an ASCII code (if<128), write 255 to clear the keyboard buffer   SIkeyInterface     Write 0 then read an ASCII code (if<128), write 255 to clear the keyboard buffer
 +  SIArrowButtons     Read state of game controller buttons
      
 ==== Refresh ==== ==== Refresh ====
Line 17: Line 19:
   init:   init:
     clr SIbaseAddress+SIrefreshOff     clr SIbaseAddress+SIrefreshOff
-    jsr ClrScrr+    jsr ClrScr
     clr SIbaseAddress+SIrefreshOn        clr SIbaseAddress+SIrefreshOn   
  
Line 45: Line 47:
 === Graphics Screen Layout === === Graphics Screen Layout ===
  
-In all modes the graphics RAM beings at $0600 and is 6K bytes long. In 2 colour mode it is 256 pixels wide by 192 pixels high. It is conventional to map the display with the top-left at (0,0) and the bottom right at (255,191) using the same virtual coordinates whatever the colour mode. Therefore in 4-colour mode pixels are 2*1 units in size, and in 15-colour mode 2*2 units.+In all modes the graphics RAM beings at $0600 and is 6K bytes long. In 2 colour mode it is 256 pixels wide by 192 pixels high. It is conventional to map the display with the top-left at (0,0) and the bottom right at (255,191) using the same virtual coordinates whatever the colour mode. Therefore in 4-colour mode pixels are 2*1 units in size, and in 16-colour mode 2*2 units.
  
   const grxBase=$0600, grxSize=$1800, gLineBytes2=$20, gLineBytes4=$20, gLineBytes16=$40   const grxBase=$0600, grxSize=$1800, gLineBytes2=$20, gLineBytes4=$20, gLineBytes16=$40
Line 59: Line 61:
 The colour palette used is the 16-colour [[https://pico-8.fandom.com/wiki/Palette|PICO-8 standard]] which provides a pleasant selection for retro video games. In 4-colour mode colours (0, 1, 2, 3) map to (0=black, 8=red, 11-green, 12=blue) respectively. In 2-colour mode colours (0, 1) map to (0, 11). The colour palette used is the 16-colour [[https://pico-8.fandom.com/wiki/Palette|PICO-8 standard]] which provides a pleasant selection for retro video games. In 4-colour mode colours (0, 1, 2, 3) map to (0=black, 8=red, 11-green, 12=blue) respectively. In 2-colour mode colours (0, 1) map to (0, 11).
  
-==== Keyboard ====+==== Text screen ==== 
 + 
 +The text screen is a memory-mapped display of the contents of 512 bytes of RAM beginning at address $0400. One byte represents one character. Values of 64..95 are the corresponding ASCII characters; 96..127 are ASCII characters 32..63. Values of 0..63 mirror those of 64+ but in inverse video. 
 + 
 +Columns and rows are zero-based with (0, 0) at the (left, top). Addresses increase left to right, then top to bottom, for a 32 wide and 16 high display. So column 7, row 3 is at address $400+(3*32)+(7). 
 + 
 +==== Keyboard & Controller ====
  
 The keyboard is accessed by a single port. Simply write 0 to the port then read from the same address. A negative value means no key has been pressed, otherwise the value is the ASCII code of the last key pressed. Write $ff to the same port to clear the keyboard buffer. The keyboard is accessed by a single port. Simply write 0 to the port then read from the same address. A negative value means no key has been pressed, otherwise the value is the ASCII code of the last key pressed. Write $ff to the same port to clear the keyboard buffer.
Line 71: Line 79:
     cmpa #escape                       ; flag Zero if ESC     cmpa #escape                       ; flag Zero if ESC
     rts     rts
 +    
 +A game controller is emulated using the keyboard. The arrow keys are for movement, plus Space and Enter can be used for 'Fire' and 'Bomb'. You can see their activity below the text screen. Read from the port to get a bitmap of these keys; logical AND with the appropriate mask to test whether a button is currently pressed or not. Note that these keys may interfere with normal functions of the HTML page such as scrolling and editing; click the Halt or Reset buttons to stop this.    
 +
 +  const ArrowLeft=$01, ArrowRight=$02, ArrowUp=$04, ArrowDown=$08
 +  const BtnFire=$10, BtnBomb=$20          
 +  readControls:  
 +    lda SIBaseAddress+SIArrowButtons
 +    bita #BtnFire
 +    bne fireWeapon
 +
 +==== Hex Dump ====
  
 +Click this button to copy a range of bytes to the system clipboard. Set the X and Y registers to specify the start and end of the range, ie. from X to Y-1. For example, if we have a program starting at $4000,  clicking **Hex Dump** with X=$4000, Y=$6000 copies $2000 bytes from $4000 to $5FFF inclusive. Now paste the text into a basic text editor and save it with extension '.hex'.
  
 +The format used is [[https://en.wikipedia.org/wiki/Intel_HEX|Intel Hex]]. It can be used directly by the [[https://www.6809.org.uk/xroar/online/|Xroar Dragon / CoCo Emulator]]. So using the example above, type CLEAR 200,16383 into the Dragon, load the '.hex' file, and execute it with EXEC 16384.
  
  
  
system_interface.1751558928.txt.gz · Last modified: 2025/07/03 16:08 by reggie

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki