💾 Archived View for mirrors.apple2.org.za › archive › ground.icaen.uiowa.edu › MiscInfo › Programmin… captured on 2023-01-29 at 10:14:22.
View Raw
More Information
-=-=-=-=-=-=-
"The Wizard of Oz" <wizard@emeraldcity.gov> wrote in message
news:pan.2004.09.02.21.57.35.198503@emeraldcity.gov...
> The source is available at
> http://www.digitalcivilization.ca/projects/projects.html. You can contact
> me directly by going to the main page and clicking on the contact us link.
> I'm a little reluctant mentioning e-mail addresses and phone numbers
> directly in newsgroups. 100 pieces of spam daily you see.
I'm fluent in Apple II but I thought I'd post a version for our web
brethren.
I'll take a look tonight.
Laine...
ORG $4000
- This set of subroutines lets the user access Double Hi
- Res in an easier way. The idea is to set up a buffer in
- a similar format to Low-Res. Specifically two four bit
- pixels per byte. A refresh of a line is done in order to
- change the graphic screen. This way the programmer does
- not have to concern themselves with plotting individual
- pixels. The plot is made to the buffer and the refresh
- takes care of displaying it in the correct location.
- Since I intend for the source to be open, I need to
- say the source is copyrighted to myself. I do not
- care if someone uses it in their program as long as
- I am given credit for the work I have done. I will
- have help with ironing out some of the bugs. Those who
- contribute code to this project should include their
- names listed below...
- DHR 0.01 - Alpha code - Unstable - Problems with the
- Refresh routine.
- Original developer: Mike Pfaiffer
- Official Source location:
- http://www.digitalcivilization.ca/projects/dhr.html
- Contributors:
- Input values in zero page
INCMD EQU $FF ; This is the command number
PARM0 EQU $FE ; Parameter 0
PARM1 EQU $FD ; Parameter 1
COL80 EQU $C00D ; Display 80 columns
STORE80 EQU $C000 ; Use ramrd and ramwt
TEXT80 EQU $C300 ; Boot 80 column card
MAINMEM EQU $C001 ; Access auxmem with page switch
TEXTON EQU $C051 ; Go to text mode
TEXTOFF EQU $C050 ; Go to graphics mode
NOMIXED EQU $C052 ; Only graphics
HIRES EQU $C057 ; Hi-res mode
IOUDISON EQU $C07E ; Disable IOU
DHRON EQU $C05E ; DHGR on if IOUDIS is on
DHROFF EQU $C05F ; Turn off DHGR
RAMR EQU $C003 ; Read from AUX ram
MAINR EQU $C002 ; Read from MAIN ram
RAMW EQU $C005 ; Write AUX ram
MAINW EQU $C004 ; Write MAIN ram
MAINZP EQU $C008 ; Use main zero page
KEYBUF EQU $200 ; Keyboard buffer
BELL EQU $FF3A ; Beep
- Location of the buffer in AUX RAM
BUFFER EQU $4000
- Command processor
- This routine gets the address of the subroutine called
- by the user and puts it in CVECTOR. Then an indirect
- jump is made to the appropriate segment.
START LDA INCMD ; Get the command from $FF (255)
ASL ; Multiply by two
TAY ; Transfer to Y
LDA COMMAND,Y ; Get and store the command handler
STA CVECTOR
INY
LDA COMMAND,Y
STA CVECTOR+1
JMP (CVECTOR) ; Use an indirect jump to the command
- This section details the various addresses
- Specifically it contains (in order) the addresses used
- by the command processor.
COMMAND DA TEXTMODE ; Turn off graphics and turn on text
DA DHIRES ; Turn on Double Hi Res graphics
DA SETCOLOUR ; Sets the current colour
DA CLRSCR ; Clear screen to the current colour
DA PLOT ; Plot a pixel as the current colour
DA REFRESH ; Refresh a line
DA REFRESHS ; Refresh the screen
CVECTOR DA $0000 ; Command Vector
- Global variables
- These contain the colour values for the current colour.
CLO DB $00 ; Colour in low nibble
CHI DB $00 ; Colour in high nibble
CBOTH DB $00 ; Colour in both
TEXTMODE STA MAINMEM
STA DHROFF
STA MAINR
STA MAINW
STA TEXTON
JSR TEXT80
RTS
- Start Double High Resolution Graphics
DHIRES STA COL80 ; Turn on 80 columns
STA TEXTOFF ; Turn on graphics
STA STORE80 ; Enable ramrd and ramwt
STA NOMIXED ; Graphics only
STA HIRES ; Start Hi-res
STA IOUDISON ; Disable IOU
STA DHRON ; Turn on DHGR
RTS
SETCOLOUR LDA PARM0
AND #$0F ; 16 colours only
STA CLO ; Low pixel
ASL ; Move four bits left
ASL
ASL
ASL
STA CHI ; High pixel
CLC
ADC CLO ; Add in lower four bits
STA CBOTH
RTS
- Clear the screen to the current colour
CLRSCR LDX #0 ; Prepare line counter
CLRLOOP LDA BUFLO,X ; Move the buffer line to safe
STA PARM1 ;zero page location
LDA BUFHI,X
STA PARM0
LDA CBOTH ; Do two pixels at once
STA RAMW ; Buffer is in aux RAM
LDY #0 ; Prepare pixel counter
PIXLOOP STA (PARM1),Y ; Store data in buffer
INY ; Next pixel
CPY #70 ; 70 bytes = 140 pixels
BNE PIXLOOP ; Not done yet
STA MAINW ; Storage now in main RAM
INX ; Next line
CPX #192 ; 192 lines
BNE CLRLOOP ; More lines to go
RTS
PLOT LDX PARM0 ; Save X until later
LDY PARM1 ; What line is it on?
LDA BUFLO,Y
STA PARM1
LDA BUFHI,Y
STA PARM0
TXA ; Upper or lower
ROR ; Divide by 2 and look at carry
TAY ; Where is the pixel?
STA RAMR ; Buffer is in aux RAM
LDA (PARM1),Y ; Get the original pixel
STA MAINR ; Read from main RAM
BCC PLOTLO ; Even pixel is low nibble
AND #$0F ; Replace high nibble of byte
ORA CHI
BCS PLOTHI
PLOTLO AND #$F0 ; Replace low nibble of byte
ORA CLO
PLOTHI STA RAMW ; Move to aux memory
STA (PARM1),Y ; Store byte with new pixel
STA MAINW ; Write main RAM
RTS
- Refresh a line
- -This is a self modifying routine
- -KBUFOUT and CLEANUP are labels used so these two addresses
- -can be accessed directly
REFRESH LDY PARM0 ; What line is to be refreshed?
STY INCMD ; Store for later use
STA MAINZP ; Be sure to use main zero page
LDA BUFHI,Y ; Get address of the line to read
STA PARM0
LDA BUFLO,Y
STA PARM1
LDA #0 ; Set up byte counter
STA KBUFOUT+1 ; Set up temporary storage in keybuf
STA CLEANUP+1
LDX #0 ; Initialize for massive loop
LDY #0
DGET STA RAMR ; Get the data from aux RAM
LDA (PARM1),Y ; Y is always 0 here
STA MAINR ; Read main RAM again
JSR BELL ; Crashes on previous instruction
MOREBITS ROR ; Rotate one bit out of A
KBUFOUT ROR KEYBUF ; Rotate one bit into key buffer
INX
INY
CPX #7 ; X counts from 0 to 6 bits
BNE XOK ; Less than 7
CLEANUP LSR KEYBUF ; Take care of last bit
INC KBUFOUT+1 ; Move on to next key buffer byte
INC CLEANUP+1
LDX #0
XOK CPY #8 ; Y counts from 0 to 7 bits
BNE MOREBITS ; Not done with the current data
CLC ; Increment buffer address
LDA #1 ;by adding 1 - because the
ADC PARM1 ;address is 16 bits
STA PARM1
LDA #0
ADC PARM0
STA PARM0
LDY #0
LDA #80 ; Done converting the line?
CMP KBUFOUT+1
BNE DGET ; Not done converting
STA MAINR ; Read from main RAM
LDY INCMD ; Now we set up the graphics
LDA LOOKUPHI,Y ;screen address in zero page
STA PARM0
LDA LOOKUPLO,Y
STA PARM1
LDY #0 ; Since we're here lets do main
LDX #1 ;RAM first
MAING LDA KEYBUF,X ; Get data
STA (PARM1),Y ; Store in graphics screen
INX ; Move on to the next
INX
INY
CPY #$28 ; Finished the line?
BNE MAING ; No
STA RAMW ; Do Aux RAM
LDY #0
LDX #0
AUXG LDA KEYBUF,X ; Get data
STA (PARM1),Y ; Store in graphics screen
INX ; Move to next
INX
INY
CPY #$28 ; Finished the line?
BNE AUXG ; No
STA MAINW ; Prepare to return
RTS
REFRESHS LDY #0 ; Start the loop
RLOOP STY PARM0 ; Save the counter twice
STY RSTORE
LDY #5 ; Set up command to refresh the line
STY INCMD
JSR START ; Refresh the line
LDY RSTORE ; Get the loop counter back
INY ; Next line
CPY #192 ; 192 lines on the screen
BNE RLOOP ; There are more lines
RTS
RSTORE DFB 0
- Buffer in aux memory - here is are the vertical values
- 140 X 192 pixels - 70 bytes per line
BUFHI DS $40,$40,$40,$40,$41,$41,$41,$41,$42,$42,$42
DS $43,$43,$43,$43,$44,$44,$44,$44,$45,$45,$45
DS $46,$46,$46,$46,$47,$47,$47,$47,$48,$48,$48
DS $49,$49,$49,$49,$4A,$4A,$4A,$4A,$4B,$4B,$4B
DS $4C,$4C,$4C,$4C,$4D,$4D,$4D,$4D,$4E,$4E,$4E
DS $4F,$4F,$4F,$4F,$50,$50,$50,$50,$51,$51,$51
DS $52,$52,$52,$52,$53,$53,$53,$53,$54,$54,$54
DS $55,$55,$55,$55,$56,$56,$56,$56,$57,$57,$57
DS $58,$58,$58,$58,$59,$59,$59,$59,$5A,$5A,$5A
DS $5B,$5B,$5B,$5B,$5C,$5C,$5C,$5C,$5D,$5D,$5D
DS $5E,$5E,$5E,$5E,$5F,$5F,$5F,$5F,$60,$60,$60
DS $61,$61,$61,$61,$62,$62,$62,$63,$63,$63,$63
DS $64,$64,$64,$64,$65,$65,$65,$66,$66,$66,$66
DS $67,$67,$67,$67,$68,$68,$68,$69,$69,$69,$69
DS $6A,$6A,$6A,$6A,$6B,$6B,$6B,$6C,$6C,$6C,$6C
DS $6D,$6D,$6D,$6D,$6E,$6E,$6E,$6F,$6F,$6F,$6F
DS $70,$70,$70,$70,$71,$71,$71,$72,$72,$72,$72
DS $73,$73,$73,$73,$74
BUFLO DS $00
DS $46,$8C,$D2,$18,$5E,$A4,$EA,$30,$76,$BC,$02
DS $48,$8E,$D4,$1A,$60,$A6,$EC,$32,$78,$BE,$04
DS $4A,$90,$D6,$1C,$62,$A8,$EE,$34,$7A,$C0,$06
DS $4C,$92,$D8,$1E,$64,$AA,$F0,$36,$7C,$C2,$08
DS $4E,$94,$DA,$20,$66,$AC,$F2,$38,$7E,$C4,$0A
DS $50,$96,$DC,$22,$68,$AE,$F4,$3A,$80,$C6,$0C
DS $52,$98,$DE,$24,$6A,$B0,$F6,$3C,$82,$C8,$0E
DS $54,$9A,$E0,$26,$6C,$B2,$F8,$3E,$84,$CA,$10
DS $56,$9C,$E2,$28,$6E,$B4,$FA,$40,$86,$CC,$12
DS $58,$9E,$E4,$2A,$70,$B6,$FC,$42,$88,$CE,$14
DS $5A,$A0,$E6,$2C,$72,$B8,$FE,$44,$8A,$D0,$16
DS $5C,$A2,$E8,$2E,$74,$BA,$00,$46,$8C,$D2,$18
DS $5E,$A4,$EA,$30,$76,$BC,$02,$48,$8E,$D4,$1A
DS $60,$A6,$EC,$32,$78,$BE,$04,$4A,$90,$D6,$1C
DS $62,$A8,$EE,$34,$7A,$C0,$06,$4C,$92,$D8,$1E
DS $64,$AA,$F0,$36,$7C,$C2,$08,$4E,$94,$DA,$20
DS $66,$AC,$F2,$38,$7E,$C4,$0A,$50,$96,$DC,$22
DS $68,$AE,$F4,$3A
- Lookup table for actual graphics screen.
LOOKUPHI DS $20,$24,$28,$2C,$30,$34,$38,$3C
DS $20,$24,$28,$2C,$30,$34,$38,$3C
DS $21,$25,$29,$2D,$31,$35,$39,$3D
DS $21,$25,$29,$2D,$31,$35,$39,$3D
DS $22,$26,$2A,$2E,$32,$36,$3A,$3E
DS $22,$26,$2A,$2E,$32,$36,$3A,$3E
DS $23,$27,$2B,$2F,$33,$37,$3B,$3F
DS $23,$27,$2B,$2F,$33,$37,$3B,$3F
DS $20,$24,$28,$2C,$30,$34,$38,$3C
DS $20,$24,$28,$2C,$30,$34,$38,$3C
DS $21,$25,$29,$2D,$31,$35,$39,$3D
DS $21,$25,$29,$2D,$31,$35,$39,$3D
DS $22,$26,$2A,$2E,$32,$36,$3A,$3E
DS $22,$26,$2A,$2E,$32,$36,$3A,$3E
DS $23,$27,$2B,$2F,$33,$37,$3B,$3F
DS $23,$27,$2B,$2F,$33,$37,$3B,$3F
DS $20,$24,$28,$2C,$30,$34,$38,$3C
DS $20,$24,$28,$2C,$30,$34,$38,$3C
DS $21,$25,$29,$2D,$31,$35,$39,$3D
DS $21,$25,$29,$2D,$31,$35,$39,$3D
DS $22,$26,$2A,$2E,$32,$36,$3A,$3E
DS $22,$26,$2A,$2E,$32,$36,$3A,$3E
DS $23,$27,$2B,$2F,$33,$37,$3B,$3F
DS $23,$27,$2B,$2F,$33,$37,$3B,$3F
LOOKUPLO DS $00,$00,$00,$00,$00,$00,$00,$00
DS $80,$80,$80,$80,$80,$80,$80,$80
DS $00,$00,$00,$00,$00,$00,$00,$00
DS $80,$80,$80,$80,$80,$80,$80,$80
DS $00,$00,$00,$00,$00,$00,$00,$00
DS $80,$80,$80,$80,$80,$80,$80,$80
DS $00,$00,$00,$00,$00,$00,$00,$00
DS $80,$80,$80,$80,$80,$80,$80,$80
DS $28,$28,$28,$28,$28,$28,$28,$28
DS $A8,$A8,$A8,$A8,$A8,$A8,$A8,$A8
DS $28,$28,$28,$28,$28,$28,$28,$28
DS $A8,$A8,$A8,$A8,$A8,$A8,$A8,$A8
DS $28,$28,$28,$28,$28,$28,$28,$28
DS $A8,$A8,$A8,$A8,$A8,$A8,$A8,$A8
DS $28,$28,$28,$28,$28,$28,$28,$28
DS $A8,$A8,$A8,$A8,$A8,$A8,$A8,$A8
DS $50,$50,$50,$50,$50,$50,$50,$50
DS $D0,$D0,$D0,$D0,$D0,$D0,$D0,$D0
DS $50,$50,$50,$50,$50,$50,$50,$50
DS $D0,$D0,$D0,$D0,$D0,$D0,$D0,$D0
DS $50,$50,$50,$50,$50,$50,$50,$50
DS $D0,$D0,$D0,$D0,$D0,$D0,$D0,$D0
DS $50,$50,$50,$50,$50,$50,$50,$50
DS $D0,$D0,$D0,$D0,$D0,$D0,$D0,$D0
SAV DHR
END
"The Wizard of Oz" <wizard@emeraldcity.gov> wrote in message
news:pan.2004.09.03.16.52.47.996968@emeraldcity.gov...
>> No rush. My time is now spoken for until Wednesday. Talk about getting
tied up fast...
Mike,
I know you're tied up. I can see the problem right off. The basic program
below will actually fix it to work but it's not the most efficient way to do
so.
Since the program is a collection of subroutines without a driver I'm
hesitant to guess exactly how you intend to use them. Will it be used
strictly from assy or will it be called from Applesoft?
Anyway if I can see a sample program I can offer a better method of storing
the routines in aux mem and accessing them.
reassemble your dhr.s at ORG $8000 and use the basic program to load it.
The DHR binary can be expanded by 169 bytes and the loader will still work.
Laine...
100 D$ = CHR$ (4)
110 PRINT D$;"BLOAD DHR.BIN"
120 FOR MEM = 768 TO 790
130 READ D: POKE MEM,D: NEXT
140 CALL 768
150 REM
160 REM PRINT D$;"BRUN DRIVER"
170 REM
200 DATA
169,0,133,60,133,62,133,66,169,128,133,61,133,67,169,133,133,63,56,32,17,195
,96