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 15:58] reggiesystem_interface [2025/07/03 16:11] (current) reggie
Line 3: Line 3:
 Emulated hardware is managed by writing to memory-mapped ports beginning at address $ff80. Emulated hardware is managed by writing to memory-mapped ports beginning at address $ff80.
  
-  const SIbaseAddress=0xff80, SIrefreshOff=0, SIrefreshOn=1, SIgraphicsMode=2, SIkeyInterface=3;+  const SIbaseAddress=$ff80 
 +  const SIrefreshOff=0, SIrefreshOn=1, SIgraphicsMode=2, SIkeyInterface=3;
  
-  SIrefreshOff             Write <any> to force OFF register refresh and display animation +  SIrefreshOff       Write <any> to force OFF register refresh and display animation 
-  SIrefreshOn              Write <any> to re-enable register refresh and display animation +  SIrefreshOn        Write <any> to re-enable register refresh and display animation 
-  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
      
 ==== Refresh ==== ==== Refresh ====
Line 16: Line 17:
   init:   init:
     clr SIbaseAddress+SIrefreshOff     clr SIbaseAddress+SIrefreshOff
-    jsr ClrScrr +    jsr ClrScr 
-    clr SIbaseAddress+SIrefreshOn +    clr SIbaseAddress+SIrefreshOn    
-    +
 ==== Graphics Mode ==== ==== Graphics Mode ====
  
Line 32: Line 33:
     lda #16     lda #16
     sta SIbaseAddress+SIgraphicsMode     sta SIbaseAddress+SIgraphicsMode
-    +
 The emulator's core OS provides an alternative method via SWI3 with the service number passed in register A and the argumnet in B: The emulator's core OS provides an alternative method via SWI3 with the service number passed in register A and the argumnet in B:
-    +
   Select4ColMode:   Select4ColMode:
     lda #$02       ; A=service number 2 (graphics mode)     lda #$02       ; A=service number 2 (graphics mode)
     ldb #$04       ; B=argument (4 colour mode)     ldb #$04       ; B=argument (4 colour mode)
     swi3     swi3
-    +
 Now all writes to the graphics display area will be interpreted in this mode. Note that to save time this does NOT effect anything already on the display until the memory is read or written. So you may need to clear the screen after selecting the mode. Now all writes to the graphics display area will be interpreted in this mode. Note that to save time this does NOT effect anything already on the display until the memory is read or written. So you may need to clear the screen after selecting the mode.
  
 === 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 1+  const grxBase=$0600, grxSize=$1800, gLineBytes2=$20, gLineBytes4=$20, gLineBytes16=$40
  
 Using 2-colour mode as an example, memory layout is from screen left to right, then top to bottom. So pixels (0,0) to (7,0) are stored in the byte at offset 0. The most significant bit in the byte represents the leftmost pixel. To represent a row of 256 pixels takes 32 bytes. So we add 32 bytes to the base address for each row moved down, thus pixel (0,1) is stored in the byte at offset 32. Using 2-colour mode as an example, memory layout is from screen left to right, then top to bottom. So pixels (0,0) to (7,0) are stored in the byte at offset 0. The most significant bit in the byte represents the leftmost pixel. To represent a row of 256 pixels takes 32 bytes. So we add 32 bytes to the base address for each row moved down, thus pixel (0,1) is stored in the byte at offset 32.
Line 52: Line 53:
 The 4-colour mode needs 2 bits for each pixel, thus to store pixels of colours of successively 0, 1, 2, 3 at coordinates (0,0), (2,0), (4,0), (6,0) would mean storing the binary value 00011011 at byte offset 0. The 4-colour mode needs 2 bits for each pixel, thus to store pixels of colours of successively 0, 1, 2, 3 at coordinates (0,0), (2,0), (4,0), (6,0) would mean storing the binary value 00011011 at byte offset 0.
  
-The 16-colour mode needs 4 bits per pixel, with 128 pixels (hence 64 bytes) per line, with only 96 lines. Thus to store colours 4 and 13 at coordinates (0,0) and (2,0) would mean storing the binary value 01001101 at byte offset 0.+The 16-colour mode needs 4 bits per pixel, with 128 pixels (hence 64 bytes) per line, with only 96 lines. Thus to store colours 4 and 13 at coordinates (128,160) and (130,160) would mean storing the binary value 01001101 at byte offset $1420.
  
 === Palette === === Palette ===
  
-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 ==== ==== Keyboard ====
system_interface.1751558291.txt.gz · Last modified: 2025/07/03 15:58 by reggie

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki