diff --git a/README.md b/README.md index 5ddff2c..467b857 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ The application logic is implemented in [petrock.asm](petrock.asm). It pulls in The application draws 16 vertical bands of the spectrum analyzer which can be up to 16 high. The program first clears the screen, draws the border and text, fills in color, and the main draw loop calls DrawBand for each one in turn. Each frame draws a new set of peaks from the PeakData table, which has 16 entries, one per band. That data is replaced either by a new frame of demo data or an incoming serial packet and the process is repeated, running at about 40 fps. -Color RAM can be filled with different patterns by stepping through the visual styles with the C key, but it is not drawn each and every frame. +Color RAM can be filled with different patterns by stepping through the visual styles with the C key, but it is not drawn each and every frame. Basic bar draw is to walk down the bar and draw a blank (when above the bar), the top of the bar, then the middle pieces, then the bottom. A visual style definition is set that includes all of the PETSCII chars you need to draw a band, like the corners and sides, etc. It can be changed with the S key. @@ -26,6 +26,7 @@ Concerning handling of serial input: In the [`settings.inc`](settings.inc) file, a number of symbols are defined that can be used to configure the build: |Name|Possible values|Mandatory|Meaning| |-|-|-|-| +|COL80|0 or 1|No|Set to 1 if your machine is fitted with an 80 column screen.| |BSNSS_KBD|0 or 1|Yes, on the PET|Set to 0 to indicate your PET has a graphical keyboard. Set to 1 to indicate it has a business keyboard. This setting is ignored on the C64.| |C64|0 or 1|No|Configure build for the Commodore 64. Exactly one of C64 or PET **must** be defined to equal 1.| |DEBUG|0 or 1|Yes|Set to 1 to enable code that only is included for debug builds.| @@ -57,7 +58,7 @@ With the cc65 toolkit installed and in your PATH, you can build the application ```text cl65 -o petrock.prg --asm-define C64=1 -t none petrock.asm ``` - + ## Loading and running Assuming the petrock.prg file is on a disk in device 8, the spectrum analyzer display can be loaded using the following command: diff --git a/petrock.asm b/petrock.asm index 990c282..584beea 100644 --- a/petrock.asm +++ b/petrock.asm @@ -16,22 +16,22 @@ ; process is repeated, running at about 40 fps. ; ; Color RAM can be filled with different patterns by stepping through the visual styles -; with the C key, but it is not drawn each and every frame. +; with the C key, but it is not drawn each and every frame. ; ; Basic bar draw is to walk down the bar and draw a blank (when above the bar), the top ; of the bar, then the middle pieces, then the bottom. A visual style definition is ; set that includes all of the PETSCII chars you need to draw a band, like the corners ; and sides, etc. It can be changed with the S key. -; +; ; Every frame the serial port is checked for incoming data which is then stored in the ; SerialBuf. If that fills up without a nul it is reset, but if a nul comess in at the ; right place (right packet size) and the magic byte matches, it is used as new peakdata ; and stored in the PeakData table. The code on the ESP32 sends it over as 16 nibbles ; packed into 8 bytes plus a VU value. ; -; The built-in serial code on the C64 is poor, and serial/c64/driver.s contains a new +; The built-in serial code on the C64 is poor, and serial/c64/driver.s contains a new ; impl that works well for receiving data up to 4800 baud. -; On the PET, built-in serial code is effectively absent. For the PET, +; On the PET, built-in serial code is effectively absent. For the PET, ; serial/c64/driver.s contains an implementation that is confirmed to receive data ; up to 2400 baud. ; @@ -60,13 +60,13 @@ ScratchStart: tempY: .res 1 ; Preserve Y Pos lineChar: .res 1 ; Line draw char SquareX: .res 1 ; Args for DrawSquare - SquareY: .res 1 - Width: .res 1 + SquareY: .res 1 + Width: .res 1 Height: .res 1 ; Height of area to draw ClearHeight: .res 1 ; Height of area to clear DataIndex: .res 1 ; Index into fakedata for demo resultLo: .res 1 ; Results from multiply operations - resultHi: .res 1 + resultHi: .res 1 VU: .res 1 ; VU Audio Data Peaks: .res NUM_BANDS ; Peak Data for current frame NextStyle: .res 1 ; The next style we will pick @@ -97,7 +97,7 @@ ScratchStart: .endif .endif -ScratchEnd: +ScratchEnd: .assert * <= SCRATCH_END, error ; Make sure we haven't run off the end of the buffer @@ -190,7 +190,7 @@ start: ldy #>clrGREEN ; Set cursor to green and clear screen, setting text lda #SER_ERR_NO_DATA + cpy #>SER_ERR_NO_DATA beq @donedata @havebyte: jsr GotSerial @@ -240,7 +240,7 @@ drawLoop: @redraw: lda RedrawFlag beq @afterdraw ; We didn't get a complete packet yet, so no point in drawing anything - lda #0 + lda #0 sta RedrawFlag ; Acknowledge packet jsr DrawVU ; Draw the VU bar at the top of the screen @@ -257,8 +257,8 @@ drawLoop: dex bpl :- -.if PET - jsr DownTextTimer ; On the PET, decrease the text timer to compensate +.if PET + jsr DownTextTimer ; On the PET, decrease the text timer to compensate .endif ; for drawing time .if SERIAL && (C64 || (PET && SENDSTAR)) @@ -314,38 +314,40 @@ drawLoop: jmp drawLoop -@notEmpty: cmp #$53 ; Letter "S" +@notEmpty: + + cmp #KEY_S bne @notStyle jsr SetNextStyle jmp drawLoop @notStyle: .if C64 ; Color only available on C64 - cmp #$43 ; Letter "C" + cmp #KEY_C bne @notColor jsr SetNextScheme jmp drawLoop -@notColor: cmp #$C3 ; Shift "C" +@notColor: cmp #KEY_C_SHIFT bne @notShiftC jsr SetPrevScheme jmp drawLoop @notShiftC: .endif - cmp #$44 ; Letter "D" + cmp #KEY_D bne @notDemo jsr SwitchDemoMode jmp drawLoop -@notDemo: cmp #$42 ; Letter "B" +@notDemo: cmp #KEY_B bne @notborder jsr ToggleBorder jmp drawLoop -@notborder: cmp #$03 +@notborder: cmp #KEY_RUNSTOP beq @exit - + jsr ShowHelp jmp drawLoop @@ -421,7 +423,7 @@ EmptyBorder: lda #0 ; ClearBorder Remove border and decorations ;----------------------------------------------------------------------------------- -ClearBorder: +ClearBorder: lda #SCREEN_MEM @@ -442,7 +444,7 @@ ClrBorderMem: ldy #XSIZE-1 ; Top line lda zptmp+1 adc #0 sta zptmp+1 - + lda #' ' ldy #0 sta (zptmp),y @@ -472,22 +474,22 @@ ClrBorderMem: ldy #XSIZE-1 ; Top line .if SERIAL ;----------------------------------------------------------------------------------- -; GotSerial Process incoming serial bytes from the ESP32 +; GotSerial Process incoming serial bytes from the ESP32 ;----------------------------------------------------------------------------------- ; Store character in serial buffer. Processes packet if character completes it. ;----------------------------------------------------------------------------------- GotSerial: ldy SerialBufPos - cpy #SerialBufLen + cpy #SerialBufLen bne @nooverflow ldy #0 sty SerialBufPos rts -@nooverflow: +@nooverflow: sta SerialBuf, y iny sty SerialBufPos - + cmp #00 ; Look for carriage return meaning end beq :+ rts ; No CR, back to caller @@ -513,20 +515,23 @@ BogusData: ; the first two bytes. Data Packet? Dave Plummer? You decide! ;----------------------------------------------------------------------------------- -GotSerialPacket: +GotSerialPacket: ldy SerialBufPos ; Get received packet length lda SerialBuf ; Look for 'D' cmp #MAGIC_BYTE_0 bne BogusData lda SerialBuf+MAGIC_LEN + .if COL80 + asl + .endif sta VU PeakDataNibbles = SerialBuf + MAGIC_LEN + VU_LEN - + ldy #0 ldx #0 - + : lda PeakDataNibbles, y ; Get the next byte from the buffer and #%11110000 ; Get the top nibble lsr @@ -535,7 +540,7 @@ GotSerialPacket: lsr clc adc #1 ; Add one to values - + sta Peaks+1, x ; Store it in the peaks table lda PeakDataNibbles, y ; Get that SAME byte from the buffer and #%00001111 ; Now we want the low nibble @@ -563,7 +568,7 @@ GotSerialPacket: ; and vu value ;----------------------------------------------------------------------------------- -FillPeaks: +FillPeaks: .if .not (PET && SERIAL) lda DemoToggle eor #$01 @@ -572,7 +577,7 @@ FillPeaks: rts -@proceed: +@proceed: .endif tya pha @@ -606,6 +611,9 @@ FillPeaks: sta zptmpB+1 ldy DataIndex lda (zptmpB), y + .if COL80 + asl + .endif sta VU lda #1 @@ -824,14 +832,14 @@ PutText: dey tya ; Calculate number of spaces to center text - clc + clc sbc #TEXT_WIDTH ; Subtract screen width from text length and invert eor #$ff ; negative result to get total whitespaces around lsr ; text. Divide that by 2. - + tax tay - + lda #' ' ; Write leading whitespace : jsr CHROUT dey @@ -1150,11 +1158,11 @@ SetPrevScheme: sta zptmpB lda #>BandSchemeTable sta zptmpB+1 - + ldy #1 ; Prep for first scheme table entry @loop: iny ; Move on to next table entry - + lda (zptmpB),y ; Check if we hit the null pointer iny ora (zptmpB),y @@ -1227,7 +1235,7 @@ FcColorMem: lda #YSIZE-TOP_MARGIN-BOTTOM_MARGIN ; Count of rows to paint c tay lda (zptmpB),y tax - iny + iny lda (zptmpB),y stx zptmpB ; ...and make that the new base address in zptmpB @@ -1288,14 +1296,17 @@ FcColorMem: lda #YSIZE-TOP_MARGIN-BOTTOM_MARGIN ; Count of rows to paint c ; No dynamic color memory ; Band Width of 2 ; -; Walks down the screen and depending on whether the current pos is above, equal, or -; below the bar itself, draws blanks, the bar top, the bar middle, bar bottom or +; Walks down the screen and depending on whether the current pos is above, equal, or +; below the bar itself, draws blanks, the bar top, the bar middle, bar bottom or ; "single-height" characters ;----------------------------------------------------------------------------------- DrawBand: sta Height ; Height is height of bar itself txa asl + .if COL80 + asl + .endif sta SquareX ; Bar xPos on screen ; Square Y will be the screen line number of the top of the bar @@ -1322,8 +1333,9 @@ lineSwitch: ldy SquareX ; Y will be the X-pos (zp addr mode not su cmp #YSIZE - BOTTOM_MARGIN - 1 bne @notlastline lda Height ; If 0 height, write blanks instead of band base - beq drawLastBlanks - cmp #1 + bne :+ + jmp drawLastBlanks +: cmp #1 beq drawOneLine bne drawLastLine @notlastline: cmp SquareY ; Compare to screen line of top of bar @@ -1334,6 +1346,12 @@ drawBlanks: lda #' ' sta (zptmp),y iny + .if COL80 + sta (zptmp),y + iny + sta (zptmp),y + iny + .endif sta (zptmp),y inc tempY bne lineLoop @@ -1341,6 +1359,13 @@ drawFirstLine: lda CharDefs + visualDef::TOPLEFTSYMBOL sta (zptmp),y iny + .if COL80 + lda CharDefs + visualDef::TOPMIDDLESYMBOL ; Draw center pieces on 80 column screens only + sta (zptmp),y + iny + sta (zptmp),y + iny + .endif lda CharDefs + visualDef::TOPRIGHTSYMBOL sta (zptmp),y inc tempY @@ -1349,6 +1374,13 @@ drawMiddleLine: lda CharDefs + visualDef::VLINE1SYMBOL sta (zptmp),y iny + .if COL80 + lda CharDefs + visualDef::HLINE1MIDDLESYMBOL ; Draw center pieces on 80 column screens only + sta (zptmp),y + iny + sta (zptmp),y + iny + .endif lda CharDefs + visualDef::VLINE2SYMBOL sta (zptmp),y inc tempY @@ -1359,6 +1391,13 @@ drawLastLine: lda CharDefs + visualDef::BOTTOMLEFTSYMBOL sta (zptmp),y iny + .if COL80 + lda CharDefs + visualDef::BOTTOMMIDDLESYMBOL ; Draw center pieces on 80 column screens only + sta (zptmp),y + iny + sta (zptmp),y + iny + .endif lda CharDefs + visualDef::BOTTOMRIGHTSYMBOL sta (zptmp),y rts @@ -1367,6 +1406,12 @@ drawOneLine: lda CharDefs + visualDef::ONELINE1SYMBOL sta (zptmp),y iny + .if COL80 + sta (zptmp),y + iny + sta (zptmp),y + iny + .endif lda CharDefs + visualDef::ONELINE2SYMBOL sta (zptmp),y rts @@ -1374,6 +1419,12 @@ drawLastBlanks: lda #' ' sta (zptmp),y iny + .if COL80 + sta (zptmp),y + iny + sta (zptmp),y + iny + .endif sta (zptmp),y rts @@ -1391,7 +1442,7 @@ lineLoop: lda zptmp ; Advance zptmp by one screen line down ;----------------------------------------------------------------------------------- ; X Cursor Y Pos ; Y Cursor X Pos -; (NOTE Reversed) +; (NOTE Reversed) (No really, pay attention, they're BACKWARDS!) ;----------------------------------------------------------------------------------- PlotEx: @@ -1402,15 +1453,16 @@ PlotEx: : jmp PLOT ; Get cursor position .endif -.if PET ; PET has no PLOT in kernal. This code is loaned from CC65's CLIB routines +.if PET ; PET has no PLOT in kernal. bcs @fetch ; Fetch values if carry set sty CURS_X stx CURS_Y - ldy CURS_Y - lda ScrLo,y + txa + asl + tay + lda ScreenLineAddresses,y sta SCREEN_PTR - lda ScrHi,y - ora #$80 ; Screen at $8000 + lda ScreenLineAddresses+1,y sta SCREEN_PTR+1 rts @@ -1426,7 +1478,7 @@ PlotEx: ; ; This routine figures out whether the C64 is connected to a 50Hz or 60Hz ; external frequency source - that traditionally being the power grid the -; AC adapter is connected to. It needs to know this to make the CIA time of +; AC adapter is connected to. It needs to know this to make the CIA time of ; day clock run at the right speed; getting it wrong makes the clock 20% off. ; This routine was effectively sourced from the following web page: ; https://codebase64.org/doku.php?id=base:efficient_tod_initialisation @@ -1447,7 +1499,7 @@ InitTODClocks: lda #$ff ; Count down from $ffff (65535) sta CIA2_TA ; Use timer A sta CIA2_TA+1 - + lda #%00010001 ; Set TOD to 60Hz mode and start the sta CIA2_CRA ; timer. @@ -1507,7 +1559,7 @@ StartTextTimer: .if PET ; We use a more rudimentary countdown timer on the PET lda #$00 sta TextCountDown - .if SERIAL ; + .if SERIAL ; lda #$20 ; Serial handling takes time, so we count .else ; down from a lower value than when lda #$40 ; serial is disabled @@ -1526,7 +1578,7 @@ DownTextTimer: lda TextTimeout beq @done - dec TextCountDown+1 ; We take off 384 just because that seems + dec TextCountDown+1 ; We take off 384 just because that seems beq @atzero ; to work out about right for one screen lda TextCountDown ; redraw. sec @@ -1665,27 +1717,36 @@ SetNextStyle: lda NextStyle ; Take the style index and multiply by 2 ; and vertical lines needed to form a box. Finally, the characters to use for bands ; of height 1 are also specified. + SkinnyRoundStyle: ; PETSCII screen codes for round tube bar style .if C64 - .byte 85, 73, 74, 75, 66, 66, 74, 75, 32, 32 + ; TL TR BL BR V1 V2 H1 H2 1L 1R TM BM H1 + .byte 85, 73, 74, 75, 66, 66, 74, 75, 32, 32, 0, 0, 0 .endif .if PET - .byte 85, 73, 74, 75, 93, 93, 74, 75, 32, 32 + ; TL TR BL BR V1 V2 H1 H2 1L 1R TM BM H1 + .byte 85, 73, 74, 75, 93, 93, 74, 75, 32, 32, 67, 70, 32 .endif DrawSquareStyle: ; PETSCII screen codes for square linedraw style - .byte 79, 80, 76, 122, 101, 103, 76, 122, 32, 32 + ; TL TR BL BR V1 V2 + .byte TOPLEFTSYMBOL, TOPRIGHTSYMBOL, BOTTOMLEFTSYMBOL, BOTTOMRIGHTSYMBOL, VLINE1SYMBOL, VLINE2SYMBOL + ; H1 H2 1L 1R TM BM H1 + .byte BOTTOMLEFTSYMBOL, BOTTOMRIGHTSYMBOL, HLINE1SYMBOL, HLINE2SYMBOL, HLINE1SYMBOL, HLINE2SYMBOL, 32 BreakoutStyle: ; PETSCII screen codes for style that looks like breakout .if C64 - .byte 239, 250, 239, 250, 239, 250, 239, 250, 239, 250 + ; TL TR BL BR V1 V2 H1 H2 1L 1R TM BM H1 + .byte 239, 250, 239, 250, 239, 250, 239, 250, 239, 250, 0, 0, 0 .endif .if PET - .byte 228, 250, 228, 250, 228, 250, 228, 250, 228, 250 + ; TL TR BL BR V1 V2 H1 H2 1L 1R TM BM H1 + .byte 228, 250, 228, 250, 228, 250, 228, 250, 228, 250, 228, 228, 228 .endif CheckerboardStyle: ; PETSCII screen codes for checkerboard style - .byte 102, 92, 102, 92, 102, 92,102, 92, 102, 92 + ; TL TR BL BR V1 V2 H1 H2 1L 1R TM BM H1 + .byte 102, 92, 102, 92, 102, 92, 102, 92, 102, 92, 102, 102, 102 ; Lookup table - each of the above mini tables is listed in this lookup table so that ; we can easily find items 0-3 @@ -1709,7 +1770,7 @@ StyleTable: ; to left. ;----------------------------------------------------------------------------------- -BandSchemeTable: +BandSchemeTable: .word RainbowScheme .word WhiteScheme .word GreenScheme @@ -1769,21 +1830,3 @@ HelpText1: .literal "C: COLOR - S: STYLE - D: DEMO", 0 HelpText1: .literal "S: STYLE - D: DEMO", 0 .endif HelpText2: .literal "B: BORDER - RUN/STOP: EXIT", 0 - -.if PET ; This is used by the PlotEx routine for the PET - -; Screen address tables - offset to real screen - -.rodata - -ScrLo: .byte $00, $28, $50, $78, $A0, $C8, $F0, $18 - .byte $40, $68, $90, $B8, $E0, $08, $30, $58 - .byte $80, $A8, $D0, $F8, $20, $48, $70, $98 - .byte $C0 - -ScrHi: .byte $00, $00, $00, $00, $00, $00, $00, $01 - .byte $01, $01, $01, $01, $01, $02, $02, $02 - .byte $02, $02, $02, $02, $03, $03, $03, $03 - .byte $03 - -.endif \ No newline at end of file diff --git a/petrock.inc b/petrock.inc index 2909606..89f09fb 100644 --- a/petrock.inc +++ b/petrock.inc @@ -30,19 +30,19 @@ BASE = $0801 ; C64 Start of BASIC PROGRAM = $0900 ; Start of actual program - + zptmp = $FB zptmpB = $FD zptmpC = $22 - + TEXT_COLOR = $0286 ; Current output color SCRATCH_START = $033C ; Datasette buffer - SCRATCH_END = $03FB ; End of datasette buffer + SCRATCH_END = $03FB ; End of datasette buffer SCREEN_MEM = $0400 ; Screen buffer of 1000 bytes - - RASTHI = $D011 ; Hiword of screen raster + + RASTHI = $D011 ; Hiword of screen raster RASTLO = $D012 ; Loword of screen raster - + COLOR_MEM = $d800 ; Screen color memory of 1000 bytes TIMERSCALE = 1022 ; Clock runs at 1.022MHz @@ -93,10 +93,13 @@ CLRSCR = $E015 YSIZE = 25 + .if COL80 + XSIZE = 80 + .else XSIZE = 40 - + .endif .endif - + ; Includes -------------------------------------------------------------------------- .include "cbm_kernal.inc" @@ -115,7 +118,7 @@ DATA_LEN = 8 ; Size of Data portion VU_LEN = 1 ; Size of VU PACKET_LENGTH = MAGIC_LEN + DATA_LEN + VU_LEN + 1 ; NUL terminated so +1 -.endif +.endif ; System Definition ----------------------------------------------------------------- @@ -127,22 +130,27 @@ CLRHOME = $93 ; Clear screen ; Defines below this line should generally not require changing NUM_BANDS = 16 ; 16 bands in the spectrum data -MAX_VU = 17 ; Maximum size per side of the VU meter ; Center the VU meter on the second screen line VUPOS1 = SCREEN_MEM + XSIZE + XSIZE / 2 + 1 +.if COL80 +VUPOS2 = SCREEN_MEM + XSIZE + 6 +.else VUPOS2 = SCREEN_MEM + XSIZE + 2 +.endif + .if C64 VUCOLORPOS = COLOR_MEM + XSIZE + 2 .endif -; Symbol definitions for square drawing - PETSCI for graphics that make a square +; Symbol definitions for square drawing - PETSCI for graphics that make a square -TOPLEFTSYMBOL = 79 +TOPLEFTSYMBOL = 79 +TOPMIDDLESYMBOL = 247 TOPRIGHTSYMBOL = 80 BOTTOMLEFTSYMBOL = 76 -BOTTOMRIGHTSYMBOL = 122 +BOTTOMRIGHTSYMBOL = 122 VLINE1SYMBOL = 101 ; Vertical line left side VLINE2SYMBOL = 103 ; Vertical line right side .if C64 @@ -158,31 +166,51 @@ VUSYMBOL = 244 ; Symbol for a filled VU square ; Classic Linedraw style - +; TL TR BL BR V1 V2 H1 H2 1L 1R TM BM H1 .struct visualDef - TOPLEFTSYMBOL .byte - TOPRIGHTSYMBOL .byte - BOTTOMLEFTSYMBOL .byte - BOTTOMRIGHTSYMBOL .byte - VLINE1SYMBOL .byte - VLINE2SYMBOL .byte - HLINE1SYMBOL .byte - HLINE2SYMBOL .byte - ONELINE1SYMBOL .byte - ONELINE2SYMBOL .byte + TOPLEFTSYMBOL .byte + TOPRIGHTSYMBOL .byte + BOTTOMLEFTSYMBOL .byte + BOTTOMRIGHTSYMBOL .byte + VLINE1SYMBOL .byte + VLINE2SYMBOL .byte + HLINE1SYMBOL .byte + HLINE2SYMBOL .byte + ONELINE1SYMBOL .byte + ONELINE2SYMBOL .byte + TOPMIDDLESYMBOL .byte + BOTTOMMIDDLESYMBOL .byte + HLINE1MIDDLESYMBOL .byte .endstruct VISUALDEF_SIZE = .sizeof(visualDef) +; Our keyboard definitions ------------------------------------------------ + +KEY_S = $53 +KEY_C = $43 +KEY_C_SHIFT = $C3 +KEY_D = $44 +KEY_B = $42 +KEY_RUNSTOP = $03 + ; Our UI Definitions ------------------------------------------------------ +.if COL80 +LEFT_MARGIN = 8 +RIGHT_MARGIN = LEFT_MARGIN +BAND_WIDTH = 4 +TOP_MARGIN = 3 +BOTTOM_MARGIN = 4 +.else LEFT_MARGIN = 4 RIGHT_MARGIN = LEFT_MARGIN BAND_WIDTH = 2 TOP_MARGIN = 3 BOTTOM_MARGIN = 4 +.endif BAND_HEIGHT = YSIZE-TOP_MARGIN-BOTTOM_MARGIN TEXT_WIDTH = XSIZE-LEFT_MARGIN-RIGHT_MARGIN - +MAX_VU = (((XSIZE-LEFT_MARGIN-RIGHT_MARGIN)/2)-1) ;---------------------------------------------------------------------------- ; Common definitions for all Commodore BASICs diff --git a/serial/pet/driver.s b/serial/pet/driver.s index d9e3d82..72551a2 100644 --- a/serial/pet/driver.s +++ b/serial/pet/driver.s @@ -157,7 +157,7 @@ StartSerial: ; state. ;----------------------------------------------------------------------------------- -CloseSerial: +CloseSerial: sei ; Disable interrupts ; Restore IRQ vector init values @@ -556,7 +556,7 @@ IrqHandler: ; 36 cycles till we hit here from IRQ firing jsr PollKeyboard ; Do keyboard polling jmp @keyend -.else ; 1200 Bd or higher => poll individual rows +.else ; 1200 Bd or higher => poll individual rows ; The following code counts down from a baud-based value (higher baudrate ; means higher value), until it reaches 11. That triggers the setting up @@ -619,7 +619,7 @@ IrqHandler: ; 36 cycles till we hit here from IRQ firing ;----------------------------------------------------------------------- ; Static data - ; Baud rate timer values, 1x baud rate + ; Baud rate timer values, 1x baud rate ; 110 300 600 1200 2400 4800 9600 BaudTblLo: .byte $83, $05, $83, $41, $A1, $D0, $68 BaudTblHi: .byte $23, $0D, $06, $03, $01, $00, $00 @@ -658,16 +658,17 @@ Log2Tbl: .byte 255,7,6,6,5,5,5,5,4,4,4,4,4,4,4,4 .if BSNSS_KBD ; Matrix for Business Keyboards -KbdMatrix: .byte '@', $0E, $F3, '8', '-', '8', '5', '2' ; $8E = BothShift+2, $1D = CursRight - .byte '9', $EF, '^', '7', '0', '7', '4', '1' - .byte '5', '\', 'k', ';', 'h', 'f', 's', $1B ; $9B = ESC - .byte '6', '[', 'l', $0D, 'j', 'g', 'd', 'a' - .byte $08, 'p', 'i', '@', 'y', 'r', 'w', $09 ; $C0 = nonshiftable ., $FF= nonshift DEL - .byte '4', ']', 'o', $F2, 'u', 't', 'e', 'q' ; $91 = CursUP. - .byte '3', $00, $19, '.', '.', 'b', 'c', $00 ; $AE-> KP. - .byte '2', $04, $0F, '0', $2C, 'n', 'v', 'z' ; Repeat->^D, $0F = Z+A+L?? - .byte '1', '/', $15, $F0, 'm', ' ', 'x', $FF ; $15 - RVS + A + L??, B1 = KP1 - .byte $16, $EF, ':', $03, '9', '6', '3', $08 ; $88 Left Arrow to BS?, ^V=TAB+<-+DEL +KbdMatrix: .byte $05, $0E, $1D, $B8, $2D, $38, $35, $32 ; $0E = both shift + 2, $1D = cursor right + .byte $B9, $EF, $DE, $B7, $30, $37, $34, $31 + .byte $B5, $3B, $4B, $DD, $48, $46, $53, $9B ; $9B = ESC + .byte $B6, $C0, $4C, $0D, $4A, $47, $44, $41 ; $0D = return + .byte $14, $50, $49, $DC, $59, $52, $57, $09 ; $14 = DEL, $09 = TAB + .byte $B4, $DB, $4F, $11, $55, $54, $45, $51 ; $11 = cursor down + .byte $B3, $00, $19, $AE, $2E, $42, $43, $00 ; $19 = left shift + TAB + I, $AE = keypad . + ; $00 = right shift, left shift, in order + .byte $B2, $10, $0F, $B0, $2C, $4E, $56, $5A ; $0F = Z + A + L, $10 = repeat + .byte $B1, $2F, $15, $13, $4D, $20, $58, $12 ; $15 - RVS + A + L, $13 = HOME, $12 = RVS + .byte $16, $04, $3A, $03, $39, $36, $33, $DF ; $16 = TAB + <- + DEL, $03 = STOP, $DF = left arrow ; Keymasks to remove modifers from the scan results ; There are backward of the table above! Above goes from 9->0, these are 0->9 @@ -679,30 +680,30 @@ CtrlMask: .byte $00, $00, $00, $00, $00, $00, $00, $00, $01, $00 ; Keyboard matrix with shift pressed, needed for consistent shifts ; Matrix for Business Keyboards -KbdMatrixShift: .byte '>', $0E, $F4, '8', '=', '(', '%', '"' ;" ;$8E = BothShift+2, $9D = CursRight - .byte '9', $EF, '^', '7', '0', $27, '$', '!' - .byte '5', '|', 'K', '+', 'H', 'F', 'S', $1B ; $1B = ESC - .byte '6', '{', 'L', $0D, 'J', 'G', 'D', 'A' - .byte $08, 'P', 'I', '@', 'Y', 'R', 'W', $09 ; $C0 = nonshiftable ., $FF= nonshift DEL - .byte '4', '}', 'O', $F1, 'U', 'T', 'E', 'Q' ; $91 = CursUP - .byte '3', $00, $19, '.', '>', 'B', 'C', $00 ; $AE-> KP. - .byte '2', $04, $0F, '0', '<', 'N', 'V', 'Z' ; Repeat->^D, $0F = Z+A+L?? - .byte '1', '?', $15, $F0, 'M', ' ', 'X', $FF ; $15 - RVS + A + L??, B1 = KP1 - .byte $16, $EF, '*', $83, ')', '&', '#', $08 ; $88 Left Arrow to BS?, ^V=TAB+<-+DEL +KbdMatrixShift: .byte '>', $0E, $F4, $B8, '=', '(', '%', '"' + .byte $B9, $EF, '^', $B7, $B0, $27, '$', '!' + .byte $B5, '|', $CB, '+', $C8, $C6, $D3, $9B + .byte $B6, '{', $CC, $0D, $CA, $C7, $C4, $C1 + .byte $08, $D0, $C9, '@', $D9, $D2, $D7, $09 + .byte $B4, '}', $CF, $F1, $D5, $D4, $C5, $D1 + .byte $B3, $00, $19, '.', '>', $C2, $C3, $00 + .byte $B2, $04, $0F, $B0, '<', $CE, $D6, $DA + .byte $B1, '?', $15, $F0, $CD, $20, $D8, $12 + .byte $16, $EF, '*', $83, ')', '&', '#', $DF .else ; Matrix for Graphics keyboards -KbdMatrix: .byte $F3, $F0, $5F, '(', '&', '%', '#', '!' - .byte $08, $F2, $EF, ')', '\', "'", '$', '"' ;" ; (Appease the syntax highlighter) - .byte '9', '7', '^', 'O', 'U', 'T', 'E', 'Q' - .byte '/', '8', $EF, 'P', 'I', 'Y', 'R', 'W' - .byte '6', '4', $EF, 'L', 'J', 'G', 'D', 'A' - .byte '*', '5', $EF, ':', 'K', 'H', 'F', 'S' - .byte '3', '1', $0D, ';', 'M', 'B', 'C', 'Z' - .byte '+', '2', $EF, '?', ',', 'N', 'V', 'X' - .byte '-', '0', $00, '>', $FF, ']', '@', $00 - .byte '=', '.', $EF, $03, '<', ' ', '[', $FF +KbdMatrix: .byte $1D, $13, $5F, $28, $26, $25, $23, $21 + .byte $14, $11, $FF, $29, $5C, $27, $24, $22 + .byte $39, $37, $5E, $4F, $55, $54, $45, $51 + .byte $2F, $38, $FF, $50, $49, $59, $52, $57 + .byte $36, $34, $FF, $4C, $4A, $47, $44, $41 + .byte $2A, $35, $FF, $3A, $4B, $48, $46, $53 + .byte $33, $31, $0D, $3B, $4D, $42, $43, $5A + .byte $2B, $32, $EF, $3F, $2C, $4E, $56, $58 + .byte $2D, $30, $00, $3E, $FF, $5D, $40, $00 + .byte $3D, $2E, $FF, $03, $3C, $20, $5B, $12 ; $88 (08) is on DEL, (Should be $94/$14) ; $5f (_) is on the <- key? @@ -717,14 +718,14 @@ CtrlMask: .byte $00, $00, $00, $00, $00, $00, $00, $00, $08, $01 ; Keyboard matrix with shift pressed, needed for consistent shifts ; Matrix for Graphics keyboards KbdMatrixShift: .byte $F4, $F0, $5F, '(', '&', '%', '#', '!' - .byte $08, $F1, $EF, ')', '\', '`', '$', '"' ;"; - .byte '9', '7', '|', $CF, $D5, $D4, $C5, $D1 - .byte '/', '8', $EF, $D0, $C9, $D9, $D2, $D7 - .byte '6', '4', $EF, $CC, $CA, $C7, $C4, $C1 - .byte '*', '5', $EF, ':', $CB, $C8, $C6, $D3 - .byte '3', '1', $0D, ';', $CD, $C2, $C3, $DA - .byte '+', '2', $EF, '?', ',', $CE, $D6, $D8 - .byte '-', '0', $00, '>', $FF, '}', '~', $00 - .byte '=', '.', $EF, $03, '<', ' ', '{', $FF + .byte $08, $F1, $FF, ')', '\', '`', '$', '"' + .byte $39, $37, '|', $CF, $D5, $D4, $C5, $D1 + .byte $2F, $38, $FF, $D0, $C9, $D9, $D2, $D7 + .byte $36, $34, $FF, $CC, $CA, $C7, $C4, $C1 + .byte $2A, $35, $FF, ':', $CB, $C8, $C6, $D3 + .byte $33, $31, $0D, ';', $CD, $C2, $C3, $DA + .byte $2B, $32, $FF, '?', ',', $CE, $D6, $D8 + .byte $2D, $30, $00, '>', $FF, '}', '~', $00 + .byte $3D, $2E, $FF, $03, '<', ' ', '{', $FF .endif diff --git a/settings.inc b/settings.inc index deede84..13468a0 100644 --- a/settings.inc +++ b/settings.inc @@ -1,4 +1,15 @@ +.ifdef COL80 + .if COL80 +BSNSS_KBD = 1 ; If 80 columns is flagged via command-line, assume we have a business keyboard + .endif +.else +COL80 = 0 ; Set to 1 if you use a PET with an 80 column display. Default is 0 (40 columns) +.endif + +.ifndef BSNSS_KBD BSNSS_KBD = 0 ; Set to 1 if you use a PET with a business keyboard. Default is 0 (graphical) +.endif + DEBUG = 0 ; Enable code that only is included for debug builds TIMING = 0 ; Change border color to show drawing progress. Only supported on the C64 SERIAL = 1 ; Enable reading serial input from user port