fixed dir tree structure
git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@3 4df02467-bbd4-4a76-a152-e7ce94205b78
This commit is contained in:
621
examples/ddrv.a
Normal file
621
examples/ddrv.a
Normal file
@@ -0,0 +1,621 @@
|
||||
;ACME 0.94
|
||||
;!sl "ddrv.l"
|
||||
; Name DuoDriver
|
||||
; Purpose Input driver for mouse and joystick
|
||||
; Author (c) Marco Baye, 1999
|
||||
; Licence Free software
|
||||
; Changes:
|
||||
; 23 Apr 1999 Release 2.20. Internal info:
|
||||
; DuoDriver v2.20 by Mac Bacon 23 Apr 1999. Freeware!
|
||||
; Somewhen Added self-calibration, forming release 3.00. Internal info:
|
||||
; Mac Bacon:DuoDrv3,PD
|
||||
; 21 Jul 1999 Used reverse subtraction, forming release 3.01. Internal info:
|
||||
; Mac Bacon:DuoDrv3,PD
|
||||
; 1 Aug 1999 Release 4.00.
|
||||
; Both 128 and 64 versions
|
||||
; Now supports overlay-sprite mouse pointer
|
||||
; Binary includes sprites
|
||||
; Released in GO64 8/1999 (without release number).
|
||||
; 3 Aug 1999 Same source file for both 128 and 64 versions. Release 4.01.
|
||||
; Apart from that, virtually identical to release 4.00.
|
||||
; 04 Feb 2003 Beautified
|
||||
; 05 Feb 2003 Added "SpriteLine" macro and made sprites inline
|
||||
; 26 May 2005 Release 4.02. All changes since release 4.00 are source-only!
|
||||
; The resulting binaries are identical to those of release 4.00
|
||||
; (which were included in GO64 magazine 8/1999)
|
||||
; 26 Mar 2006 Release 4.03. Adjusted source to ACME 0.91 capabilities.
|
||||
; 25 Nov 2007 Release 4.04. Adjusted source to ACME 0.94 capabilities.
|
||||
|
||||
; This source code file uses conditional assembly
|
||||
; to decide which version to produce (C64 or C128).
|
||||
|
||||
; Select type of binary to assemble (64 => c64, anything else => c128)
|
||||
!ifndef SYSTEM {
|
||||
!warn "Label SYSTEM not defined. Use -DSYSTEM=64 to build C64 version, -DSYSTEM=128 to build C128 version. Will now default to C64 version."
|
||||
SYSTEM = 64
|
||||
}
|
||||
!if SYSTEM != 64 & SYSTEM != 128 {
|
||||
!serious "Please use either -DSYSTEM=64 or -DSYSTEM=128 when assembling this project."
|
||||
}
|
||||
|
||||
|
||||
; --- Configurable values
|
||||
|
||||
; Start address, output file name and VIC location
|
||||
|
||||
!if SYSTEM = 64 {
|
||||
*=$c000
|
||||
!to "ddrv64.prg", cbm
|
||||
VIC_Base = $d000
|
||||
}
|
||||
!if SYSTEM = 128 {
|
||||
*=$0c00
|
||||
!to "ddrv128.prg", cbm
|
||||
VIC_Base = $11d6; Location of mirror registers
|
||||
}
|
||||
|
||||
; Pointer's maximum coordinates
|
||||
MaximumCoordinateX = 319; VIC value
|
||||
; MaximumCoordinateX = 639; VDC value
|
||||
MaximumCoordinateY = 199
|
||||
|
||||
; Maximum pixel step size ("speed") for joystick acceleration routine.
|
||||
MaxStep = $10; (max. $7f)
|
||||
|
||||
; Distance before acceleration starts, in pixels.
|
||||
MaxTime = $04; (max. $7f)
|
||||
|
||||
; Sprites to use for overlay pointer
|
||||
Sprite_A = 0
|
||||
Sprite_B = 1
|
||||
|
||||
; Coordinates of "pointer pixel" within pointer sprites; adjust these
|
||||
; if you use different sprites. (0,0) is sprite's upper left pixel.
|
||||
Sprite_HotspotX = 1
|
||||
Sprite_HotspotY = 1
|
||||
|
||||
; Locations to store button states, $ff = pressed, $00 = not pressed.
|
||||
; Mouse uses both buttons, joystick only uses "LeftButton".
|
||||
; Location to store pointer's current character coordinates.
|
||||
!if SYSTEM = 64 {
|
||||
LeftButton = $a4
|
||||
RightButton = $a5
|
||||
CharX = $b3
|
||||
CharY = $b4
|
||||
}
|
||||
!if SYSTEM = 128 {
|
||||
LeftButton = $fa
|
||||
RightButton = $ff
|
||||
CharX = $9b
|
||||
CharY = $9c
|
||||
}
|
||||
|
||||
; Location to store pointer's current pixel coordinates. The driver
|
||||
; code relies on having *four consecutive* bytes:
|
||||
; x low, x high, y low, y high
|
||||
Coordinates = $fb; $fb-$fe
|
||||
|
||||
|
||||
; --- System constants
|
||||
|
||||
; Interrupt vector
|
||||
sys_iirq = $0314
|
||||
|
||||
; I/O registers
|
||||
sid_pot = $d419
|
||||
cia1_pra = $dc00
|
||||
cia1_prb = $dc01
|
||||
cia1_ddrb = $dc03
|
||||
mmu_cr = $ff00; c128 only
|
||||
|
||||
|
||||
; --- Label definitions
|
||||
|
||||
; New names for some precalculated values, only to improve
|
||||
; readability. Don't change these.
|
||||
PointerXnow = Coordinates
|
||||
PointerYnow = Coordinates + 2
|
||||
SpriteA_X = VIC_Base + 2*Sprite_A
|
||||
SpriteA_Y = VIC_Base + 2*Sprite_A + 1
|
||||
SpriteB_X = VIC_Base + 2*Sprite_B
|
||||
SpriteB_Y = VIC_Base + 2*Sprite_B + 1
|
||||
Sprites_OF = VIC_Base + 16; X Overflow
|
||||
; The character "^" in the following calculation means "to the power
|
||||
; of". It is ACME syntax - if your assembler cannot do this, you may
|
||||
; want to use hardcoded values here instead of calculations.
|
||||
Sprites_Bitmask = 2^Sprite_A + 2^Sprite_B
|
||||
;alternative:
|
||||
; Sprites_Bitmask = 1<<Sprite_A | 1<<Sprite_B
|
||||
SpriteOffset_X = $18 - Sprite_HotspotX
|
||||
SpriteOffset_Y = $32 - Sprite_HotspotY
|
||||
; In the sprite coordinate system, the graphics pixel (0,0) has the
|
||||
; coordinates ($18,$32), so these are needed for converting. Blame the
|
||||
; VIC.
|
||||
|
||||
|
||||
; --- Entry point
|
||||
|
||||
; Because this routine is the first, the file can be BOOTed on a c128.
|
||||
; Initialisation code, installs driver on IRQ vector.
|
||||
; Fetch IRQ vector and write to end
|
||||
Init lda sys_iirq
|
||||
ldx sys_iirq+1
|
||||
sta mod16
|
||||
stx mod16+1
|
||||
; Let IRQ vector point to driver code
|
||||
lda #<Entry
|
||||
ldx #>Entry
|
||||
php
|
||||
sei
|
||||
sta sys_iirq
|
||||
stx sys_iirq+1
|
||||
plp
|
||||
!if SYSTEM=128 {
|
||||
lda mmu_cr
|
||||
tay
|
||||
and #$fe; activate I/O chips
|
||||
sta mmu_cr
|
||||
}
|
||||
|
||||
; Init mouse buttons
|
||||
lda #$11
|
||||
sta cia1_prb
|
||||
!if SYSTEM=128 {sty mmu_cr }
|
||||
|
||||
!if SYSTEM = 64 {
|
||||
; Copy sprites to tape buffer
|
||||
ldx #127
|
||||
- lda Sprites,x
|
||||
sta $0340,x
|
||||
dex
|
||||
bpl -
|
||||
lda #Sprites_Bitmask
|
||||
; Set sprite block pointers
|
||||
ldx #$0d
|
||||
stx 2040+Sprite_A
|
||||
inx
|
||||
stx 2040+Sprite_B
|
||||
; Activate pointer sprites
|
||||
ora VIC_Base+21
|
||||
sta VIC_Base+21
|
||||
}
|
||||
rts
|
||||
|
||||
|
||||
; --- Variables
|
||||
|
||||
; Pixel counter before accelerating
|
||||
JoyWaittime !byte 0
|
||||
|
||||
|
||||
; --- Main code
|
||||
|
||||
Entry
|
||||
; The driver consists of several distinct parts. To minimise
|
||||
; performance wastage, you should remove all parts you don't need for
|
||||
; the specific application.
|
||||
|
||||
|
||||
; --- Part 0, initialisations
|
||||
|
||||
; Make sure decimal mode is off
|
||||
cld
|
||||
; Set button states to "not pressed", so the other parts only have to
|
||||
; deal with setting them to "pressed".
|
||||
lda #$00
|
||||
sta LeftButton
|
||||
sta RightButton
|
||||
|
||||
|
||||
; --- Part 1, handling mouse movements
|
||||
|
||||
; mouse x
|
||||
ldx #$00; 0 means "x stuff"
|
||||
jsr PotDelta
|
||||
; Now signed x movement is in A/Y. Add to current x value.
|
||||
clc
|
||||
adc PointerXnow
|
||||
sta PointerXnow
|
||||
tya
|
||||
adc PointerXnow+1
|
||||
sta PointerXnow+1
|
||||
; mouse y
|
||||
ldx #$01; 1 means "y stuff"
|
||||
jsr PotDelta
|
||||
; Now signed y movement is in A/Y. Mouse and computer use different y
|
||||
; directions, so don't add to, but subtract from current y value.
|
||||
; This is a reverse subtraction - it might be harder to understand,
|
||||
; but it is both faster and smaller than the usual way.
|
||||
clc
|
||||
sbc PointerYnow
|
||||
eor #$ff
|
||||
sta PointerYnow
|
||||
tya
|
||||
sbc PointerYnow+1
|
||||
eor #$ff
|
||||
sta PointerYnow+1
|
||||
|
||||
|
||||
; --- Part 2, handling mouse buttons
|
||||
|
||||
; Prepare CIA by setting bits to input
|
||||
ldy #$11
|
||||
sty cia1_ddrb
|
||||
ldx #$ff; $ff means "pressed"
|
||||
lda #$10; check left button
|
||||
bit cia1_prb
|
||||
bne +
|
||||
stx LeftButton; store state
|
||||
+ lda #$01; check right button
|
||||
bit cia1_prb
|
||||
bne +
|
||||
stx RightButton; store state
|
||||
; Reset CIA to normal state
|
||||
+ ldy #$00
|
||||
sty cia1_ddrb
|
||||
|
||||
|
||||
; --- Part 3, handling the joystick
|
||||
|
||||
; Fetch byte holding direction flags
|
||||
lda cia1_pra
|
||||
tax; ...and remember it
|
||||
; Check 'up' direction
|
||||
ror
|
||||
bcs ++
|
||||
; Subtract current step size from y value if needed.
|
||||
tay
|
||||
sec
|
||||
lda PointerYnow
|
||||
sbc JoyStepsize
|
||||
sta PointerYnow
|
||||
bcs +
|
||||
dec PointerYnow+1
|
||||
+ tya
|
||||
; Check 'down' direction
|
||||
++ ror
|
||||
bcs ++
|
||||
; Add current step size to y value if needed.
|
||||
tay
|
||||
;clc; C is always clear here
|
||||
lda PointerYnow
|
||||
adc JoyStepsize
|
||||
sta PointerYnow
|
||||
bcc +
|
||||
inc PointerYnow+1
|
||||
+ tya
|
||||
; Check 'left' direction
|
||||
++ ror
|
||||
bcs ++
|
||||
; Subtract current step size from x value if needed.
|
||||
tay
|
||||
sec
|
||||
lda PointerXnow
|
||||
sbc JoyStepsize
|
||||
sta PointerXnow
|
||||
bcs +
|
||||
dec PointerXnow+1
|
||||
+ tya
|
||||
; Check 'right' direction
|
||||
++ ror
|
||||
bcs ++
|
||||
; Add current step size to x value if needed.
|
||||
tay
|
||||
;clc; C is always clear here
|
||||
lda PointerXnow
|
||||
adc JoyStepsize
|
||||
sta PointerXnow
|
||||
bcc +
|
||||
inc PointerXnow+1
|
||||
+ tya
|
||||
++
|
||||
|
||||
; --- Part 4, handling joystick button
|
||||
|
||||
ror
|
||||
bcs +
|
||||
lda #$ff; $ff means "pressed"
|
||||
sta LeftButton
|
||||
+
|
||||
|
||||
; --- Part 5, joystick acceleration
|
||||
|
||||
; Restore joystick direction bits and check whether to set speed to
|
||||
; zero.
|
||||
txa
|
||||
and #$0f; Clear unneeded bits
|
||||
cmp #$0f; Any direction bit ?
|
||||
bne +
|
||||
; No direction was used, so reset speed and wait counter to normal.
|
||||
lda #$01
|
||||
sta JoyStepsize
|
||||
lda #MaxTime
|
||||
sta JoyWaittime
|
||||
jmp Part5End
|
||||
+
|
||||
; A direction bit was used, so check whether to accelerate: If speed
|
||||
; is already maximum speed, don't accelerate.
|
||||
JoyStepsize=*+1
|
||||
lda #$00; (self-modifying)
|
||||
; If the variable "JoyStepsize" would have been defined as a separate
|
||||
; location (using "!byte"), it would have taken a byte of memory. By
|
||||
; storing the value inside an LDA command's argument, we save that one
|
||||
; byte. It might make a difference. :)
|
||||
cmp #MaxStep; If speed is max.,
|
||||
bcs Part5End; don't accelerate.
|
||||
; Speed isn't maximum yet. Check whether
|
||||
; we have to wait before accelerating.
|
||||
dec JoyWaittime
|
||||
bpl Part5End
|
||||
; Counter has underrun, so accelerate.
|
||||
inc JoyWaittime; reset counter
|
||||
inc JoyStepsize; increase speed
|
||||
Part5End
|
||||
|
||||
; --- Part 6, restrict coordinate range
|
||||
|
||||
; restrict x value
|
||||
ldx #$00; 0 means "x stuff"
|
||||
jsr Restrict
|
||||
; restrict y value
|
||||
ldx #$02; 2 means "y stuff"
|
||||
jsr Restrict
|
||||
|
||||
; --- Part 7, positioning sprites
|
||||
|
||||
; Set sprites' x positions
|
||||
lda PointerXnow
|
||||
clc
|
||||
adc #SpriteOffset_X
|
||||
sta SpriteA_X; set both sprites
|
||||
sta SpriteB_X
|
||||
lda Sprites_OF; get x overflow
|
||||
bcs SetOF
|
||||
ldx PointerXnow+1
|
||||
bne SetOF
|
||||
and #Sprites_Bitmask XOR $ff
|
||||
bcc StoreOF; C is clear here
|
||||
SetOF ora #Sprites_Bitmask
|
||||
StoreOF sta Sprites_OF; set x overflow
|
||||
|
||||
; Set sprites' y positions
|
||||
lda PointerYnow
|
||||
clc
|
||||
adc #SpriteOffset_Y
|
||||
sta SpriteA_Y
|
||||
sta SpriteB_Y
|
||||
; The y value's high byte is useless in this case.
|
||||
|
||||
; --- Part 8, making char coordinates
|
||||
|
||||
; Convert x coordinate. There are different "best" routines for
|
||||
; different resolutions, so I've given the VIC and VDC routines.
|
||||
lda PointerXnow
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
ldx PointerXnow+1
|
||||
;ora OrTable,x; VDC only (see below for data table)
|
||||
beq +; VIC only
|
||||
ora #$20; VIC only
|
||||
+ sta CharX
|
||||
|
||||
; Convert y coordinate.
|
||||
lda PointerYnow
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
sta CharY
|
||||
|
||||
; --- Add further parts here
|
||||
|
||||
; Here you can add further routines, for example to use the button
|
||||
; states to fake keypresses etc.
|
||||
|
||||
; --- The end
|
||||
|
||||
; The initialisation routine sets the argument to the address of the
|
||||
; previous IRQ routine.
|
||||
mod16=*+1: jmp $ffff; (self-modifying)
|
||||
|
||||
; This table is for part 8.
|
||||
;OrTable !byte 0,32,64; VDC only
|
||||
|
||||
; --- "Restrict" subroutine
|
||||
|
||||
PointerXmax !word MaximumCoordinateX
|
||||
PointerYmax !word MaximumCoordinateY
|
||||
; "y" word must follow directly after "x" word in memory.
|
||||
|
||||
Restrict
|
||||
; Restrict internal coordinates to configured range. Entry conditions:
|
||||
; X is direction handle (0 = x, 2 = y)
|
||||
lda PointerXnow+1,x
|
||||
bmi SetTo0
|
||||
cmp PointerXmax+1,x
|
||||
bcc Eosr
|
||||
bne +
|
||||
lda PointerXmax,x
|
||||
cmp PointerXnow,x
|
||||
bcs Eosr
|
||||
+ lda PointerXmax,x
|
||||
ldy PointerXmax+1,x
|
||||
jmp DefCo
|
||||
SetTo0 lda #0
|
||||
tay
|
||||
DefCo sta PointerXnow,x
|
||||
sty PointerXnow+1,x
|
||||
Eosr rts
|
||||
|
||||
; --- "Pot" subroutine
|
||||
|
||||
; This routine computes the mouse movements and therefore contains the
|
||||
; self-calibration stuff and the other improvements over the standard
|
||||
; 1351 driver.
|
||||
PotMax !word 0; max. POTs yet plus 1 !
|
||||
PotMin !word $ffff; lowest POTs yet
|
||||
PotOld !word 0; old values
|
||||
PotWidth !word 0; interval width
|
||||
HalfPotWidth !word 0; half width
|
||||
; (buffered for speed increase)
|
||||
; The above variables are not really words: The first byte is the x
|
||||
; value, the second byte is the y value respectively.
|
||||
|
||||
|
||||
; Compute the signed distance of mouse movement.
|
||||
; Entry conditions: X is direction handle (0 = x, 1 = y)
|
||||
; Exit conditions: A/Y are signed distance (low/high)
|
||||
|
||||
; First, get new value and clear "recalculate signal width" flag.
|
||||
PotDelta lda sid_pot,x
|
||||
ldy #$00
|
||||
; Check whether new value is lower than lowest known.
|
||||
cmp PotMin,x
|
||||
bcs +
|
||||
; Store new "lowest" und set "recalculate signal width" flag.
|
||||
sta PotMin,x
|
||||
ldy #$ff
|
||||
+ ; Check whether new value is higher than highest known.
|
||||
cmp PotMax,x
|
||||
bcc +
|
||||
; Set "recalculate signal width" flag and store new "highest".
|
||||
ldy #$ff
|
||||
pha; Remember current value
|
||||
adc #$00; Add one (C is set)
|
||||
sta PotMax,x
|
||||
; Value $ff (0 after adding) means that there is no mouse connected,
|
||||
; so reset min/max in that case.
|
||||
beq ResetMM; Stack is untidy...
|
||||
pla; Restore current value
|
||||
+ ; If flag is set, recalculate signal width.
|
||||
iny; Check flag
|
||||
bne ++
|
||||
tay; Buffer current value.
|
||||
lda PotMax,x; Get highest+1
|
||||
sec; Subtract lowest
|
||||
sbc PotMin,x
|
||||
bcc +
|
||||
sta PotWidth,x; Store signal
|
||||
lsr; width and half signal
|
||||
sta HalfPotWidth,x; width
|
||||
+ tya; Restore current value.
|
||||
++ ; Calculate distance
|
||||
tay; Buffer current value.
|
||||
sec
|
||||
sbc PotOld,x
|
||||
pha
|
||||
tya
|
||||
sta PotOld,x
|
||||
pla
|
||||
beq zero; If not moved, exit.
|
||||
bcc minus; Negative difference
|
||||
|
||||
; Positive difference:
|
||||
; Check whether movement caused a value wrap-around.
|
||||
cmp HalfPotWidth,x
|
||||
bcc Decrease
|
||||
beq Decrease
|
||||
; It did, so calculate "real" distance and jump to exit
|
||||
;sec; C is always set here
|
||||
sbc PotWidth,x; Fix distance
|
||||
|
||||
; We now know that the (fixed) distance is really negative, so we
|
||||
; finally wipe out that annoying bit 0 noise by incrementing the
|
||||
; value.
|
||||
Increase ;clc; C is always clear here
|
||||
adc #$01
|
||||
beq zero; If increasing gives zero, jump to zero handler.
|
||||
ldy #$ff; Set up high byte for negative values.
|
||||
rts
|
||||
|
||||
; Negative difference:
|
||||
; Check whether movement caused a value wrap-around.
|
||||
minus eor #$ff; Complement
|
||||
; If we would do a real negation (by adding "1"), then we would need
|
||||
; to branch using BCC *and* BEQ. So the above way might be harder to
|
||||
; understand, but it is both shorter *and* faster - which I like. :)
|
||||
cmp HalfPotWidth,x
|
||||
eor #$ff; Restore value
|
||||
bcc Increase
|
||||
; Movement caused a value wrap-around, so calculate "real" distance and exit.
|
||||
clc
|
||||
adc PotWidth,x; Fix distance
|
||||
|
||||
; We now know that the (fixed) distance is really positive, so we
|
||||
; finally wipe out that annoying bit 0 noise by decrementing the value.
|
||||
Decrease sec
|
||||
sbc #$01
|
||||
|
||||
; No difference or positive difference; both need zero as the high byte.
|
||||
zero ldy #0
|
||||
rts
|
||||
|
||||
; If there is no mouse, reset "lowest" ("highest" will have been reset
|
||||
; already) and return zero.
|
||||
ResetMM tay; Set Y to zero.
|
||||
pla; Tidy stack
|
||||
lda #$ff; Reset "lowest"
|
||||
sta PotMin,x
|
||||
tya; Return with A/Y = 0
|
||||
rts
|
||||
|
||||
; --- Include sprites
|
||||
|
||||
; Because the c64 version copies the sprite data into the tape buffer
|
||||
; on initialisation, the data is included right here.
|
||||
; In the c128 version, we skip memory until we reach $0e00 - this is
|
||||
; where the sprites are stored by default.
|
||||
|
||||
!if SYSTEM = 128 {
|
||||
!align $ffff, $e00, $0
|
||||
}
|
||||
|
||||
!macro SpriteLine .v {
|
||||
!by .v>>16, (.v>>8)&255, .v&255
|
||||
}
|
||||
|
||||
Sprites ; 765432107654321076543210
|
||||
+SpriteLine %........................
|
||||
+SpriteLine %.#......................
|
||||
+SpriteLine %.##.....................
|
||||
+SpriteLine %.###....................
|
||||
+SpriteLine %.####...................
|
||||
+SpriteLine %.#####..................
|
||||
+SpriteLine %.######.................
|
||||
+SpriteLine %.#######................
|
||||
+SpriteLine %.########...............
|
||||
+SpriteLine %.#########..............
|
||||
+SpriteLine %.########...............
|
||||
+SpriteLine %.######.................
|
||||
+SpriteLine %.######.................
|
||||
+SpriteLine %.##..##.................
|
||||
+SpriteLine %.#....##................
|
||||
+SpriteLine %......##................
|
||||
+SpriteLine %.......##...............
|
||||
+SpriteLine %.......##...............
|
||||
+SpriteLine %........##..............
|
||||
+SpriteLine %........##..............
|
||||
+SpriteLine %........................
|
||||
!byte 0; pad to 64-byte block
|
||||
; 765432107654321076543210
|
||||
+SpriteLine %##......................
|
||||
+SpriteLine %###.....................
|
||||
+SpriteLine %####....................
|
||||
+SpriteLine %#####...................
|
||||
+SpriteLine %######..................
|
||||
+SpriteLine %#######.................
|
||||
+SpriteLine %########................
|
||||
+SpriteLine %#########...............
|
||||
+SpriteLine %##########..............
|
||||
+SpriteLine %###########.............
|
||||
+SpriteLine %###########.............
|
||||
+SpriteLine %#########...............
|
||||
+SpriteLine %########................
|
||||
+SpriteLine %########................
|
||||
+SpriteLine %###..####...............
|
||||
+SpriteLine %##...####...............
|
||||
+SpriteLine %......####..............
|
||||
+SpriteLine %......####..............
|
||||
+SpriteLine %.......####.............
|
||||
+SpriteLine %.......####.............
|
||||
+SpriteLine %........###.............
|
||||
BIN
examples/ddrv128.exp
Normal file
BIN
examples/ddrv128.exp
Normal file
Binary file not shown.
BIN
examples/ddrv64.exp
Normal file
BIN
examples/ddrv64.exp
Normal file
Binary file not shown.
74
examples/macedit.a
Normal file
74
examples/macedit.a
Normal file
@@ -0,0 +1,74 @@
|
||||
;ACME 0.94
|
||||
; ist der komplette Sourcecode von MacEdit
|
||||
; (80-Zeichen-Version)
|
||||
; Version 0.7
|
||||
; Weitere Informationen am Ende der Datei
|
||||
; Parameter:
|
||||
!to "macedit.o", cbm
|
||||
;!sl "macedit.l"
|
||||
*= $1300
|
||||
!ct pet
|
||||
!source <6502/std.a>
|
||||
!ifndef Lib_6502_std_a {
|
||||
!serious "To assemble this program, you need to install the ACME library."
|
||||
}
|
||||
!source "me/macros.a"
|
||||
!source "me/const.a"
|
||||
; Code:
|
||||
jmp init ; zum Programm
|
||||
!text "TekFile", 0 ; DateiFormat + 'program'
|
||||
!word progend - keyb ; length
|
||||
|
||||
; Gelinkt wird:
|
||||
keyb
|
||||
!binary "me/tables.bin", 826
|
||||
keytabs = keyb + 12 ; 6 Tastaturtabs &
|
||||
atst = keytabs + $22e ; ASCII-2-Screen-Tabelle
|
||||
|
||||
!source "me/vars.a"
|
||||
!source "me/core.a"
|
||||
!source "me/file.a"
|
||||
!source "me/out.a"
|
||||
!source "me/cursor.a"
|
||||
|
||||
linebuf
|
||||
progend = linebuf+128
|
||||
!byte 0 ; 128 Byte Zeilenpuffer
|
||||
|
||||
!eof
|
||||
|
||||
<EFBFBD>nderungen von Version 0.6 zu Version 0.7:
|
||||
Das DCS-Window wurde implementiert, dadurch wurde auch ein Unterschied zwischen "Beenden" und "Basic" eingebaut (Bei ersterem erfolgt die DCS-Abfrage).
|
||||
Die Strings der Windows liegen jetzt nicht mehr als Screencodes vor, sondern als PetSCII-Werte; die Routine ".makewin" konvertiert dies also.
|
||||
Die Bedeutung des Flags "unnamed" wurde invertiert.
|
||||
|
||||
Sp<EFBFBD>tere <20>nderungen am Source:
|
||||
|
||||
19. 4.1997: Durch Weiterentwicklung von V0.6 erzeugt (kommentarlos)
|
||||
24. 9.1998: Kommentare von V0.6 wieder hinzugef<65>gt
|
||||
25. 9.1998: Umformatierung auf ACME-Syntax
|
||||
10.10.1998: Ersetzen von "{" und "}" in Labels durch "_" und "__"
|
||||
12.10.1998: Unterschiede zu v0.6 dokumentiert.
|
||||
30.10.1998: "+ =" wieder zu "+=" korrigiert.
|
||||
1.11.1998: Alle Labels wieder globalisiert.
|
||||
2.11.1998: Tabulatorlayout wieder korrigiert und "~" durch "___" ersetzt.
|
||||
3.11.1998: Label "notmany!" durch "notmany" ersetzt. Wo kam das blo<6C> her ?
|
||||
4.11.1998: Zwei fehlerhafte Auskommentierungen entsorgt. Die Stellen wurden mit "**mark**" gekennzeichnet. Wo kam das blo<6C> her ? Au<41>erdem wurde "< = >" in einem Textstring wieder zu "<=>" korrigiert. Das ist wohl beim automatischen Layout passiert.
|
||||
4.11.1998: Top-Bit-Set-Zeichen aus Textstrings enfernt und byteweise eingef<65>gt, z.B. auch "Cursor up/down/left/right"-Werte. Au<41>erdem alle Filenamen angepa<70>t.
|
||||
5.11.1998: Auch die Umlaute nun zu Bytewerten gewandelt.
|
||||
19.11.1998: "!cbm" eingef<65>gt, da ge<67>nderte ACME-Funktion "!text".
|
||||
24.11.1998: Filenamen bei "!to" und "!bin" auf UNIX-Stil gebracht.
|
||||
27.11.1998: Aufeinanderfolgende "!tx" und "!by" gemerged, BIT-Trick benutzt, Hexzahlen auf lowercase gebracht, Bin<69>rzahlen auf Spezialformat gebracht, Einr<6E>ckungen dezimiert, Zahlen durch Label ersetzt, "firsttry" in "repeatedtry" umbenannt (war vorher unlogisch).
|
||||
28.11.1998: Auf Benutzung von Modulen und lokalen Labels umgestellt.
|
||||
30.11.1998: Alle "!module" durch "!zone" ersetzt (wegen ACME-<2D>nderung).
|
||||
1.12.1998: Mehrere Labels pro Zeile entzerrt (wegen ACME-<2D>nderung).
|
||||
2.12.1998: Multifile-Version, <20>nderungstext ans Ende verschoben.
|
||||
10.12.1998: Makros eingebaut.
|
||||
8. 1.1999: Library benutzt und daher Branch-Makros gel<65>scht, au<61>erdem BIT-Trick durch Makroaufruf ersetzt.
|
||||
24. 8.1999: An die leicht ge<67>nderte Syntax von ACME 007 angepa<70>t.
|
||||
|
||||
04 Jun 2005:
|
||||
Adjusted to ACME 0.86 syntax (added output file format indicator).
|
||||
26 Mar 2006:
|
||||
Adjusted to ACME 0.91 syntax (anonymous labels)
|
||||
Now throws serious error if the library file could not be loaded.
|
||||
BIN
examples/macedit.exp
Normal file
BIN
examples/macedit.exp
Normal file
Binary file not shown.
93
examples/me/const.a
Normal file
93
examples/me/const.a
Normal file
@@ -0,0 +1,93 @@
|
||||
;ACME 0.91
|
||||
|
||||
; Konstanten:
|
||||
FALSE = 0 ; Das Programm verl<72><6C>t sich an etlichen Stellen
|
||||
TRUE = $ff ; darauf, da<64> genau diese Werte zugewiesen wurden.
|
||||
MODIFIED8 = $ff ; Defaultwerte f<>r
|
||||
MODIFIED16 = $ffff ; Selbstmodifikationen
|
||||
|
||||
Char_NUL = $00
|
||||
Char_STOP = $03
|
||||
Char_RETURN = $0d
|
||||
Char_CursorDown = $11
|
||||
Char_HOME = $13
|
||||
Char_DEL = $14
|
||||
Char_ESCAPE = $1b
|
||||
Char_CursorRight= $1d
|
||||
Char_At = $40
|
||||
CharOwn_Delete = $74
|
||||
Char_ShiftRETURN= $8d
|
||||
Char_CursorUp = $91 ; Diese Werte waren fr<66>her als Strings angegeben.
|
||||
Char_CLEAR = $93
|
||||
Char_INST = $94
|
||||
Char_Grey2 = $98
|
||||
Char_BlueL = $9a
|
||||
Char_Grey3 = $9b
|
||||
Char_CursorLeft = $9d
|
||||
_ = 1 ; Dieser Code steht f<>r das unsichtbare Space in den Windows.
|
||||
|
||||
<09> = $bb ; Werte um Umlaute verwenden zu k<>nnen.
|
||||
<09> = $bc
|
||||
<09> = $bd
|
||||
<09> = $be
|
||||
<09> = $db
|
||||
<09> = $dc
|
||||
<09> = $dd
|
||||
|
||||
chrol = 104 ; Fensterrahmen
|
||||
chroo = 102
|
||||
chror = 106
|
||||
chrll = 97
|
||||
chrmm = 32
|
||||
chrrr = 97
|
||||
chrul = 98
|
||||
chruu = 102
|
||||
chrur = 100
|
||||
lf = 8 ; Filenr. & Sek.-Addy
|
||||
|
||||
; Zeropage:
|
||||
D8502 = $00 ; Direction
|
||||
R8502 = $01 ; Register
|
||||
vvek = $83 ; Vektor auf LineVektor
|
||||
lvek = $85 ; LineVektor
|
||||
tmp1 = $87
|
||||
tmp2 = $89
|
||||
vtemp = $8d ; crsr-address (3) ; zeropage (**mark**)
|
||||
status = $90 ; System variable ST
|
||||
fnlen = $b7 ; Dateiparameter
|
||||
fnbank = $c7 ; Bank of file name
|
||||
ndx = $d0 ; Tasten- &
|
||||
kyndx = $d1 ; F- Buffer
|
||||
keyidx = $d2 ; F-Zeichenz<6E>hler
|
||||
mode = $d7 ; Bit 7 = Cursorscreen (40/80)
|
||||
color = $f1 ; current attribute
|
||||
locks = $f7 ; Verhindert CBM-Shift
|
||||
beep = $f9 ; Tastenklick
|
||||
lftb = $fa ; Maustasten
|
||||
rgtb = $fb
|
||||
line = $fc ; Z<>hler
|
||||
col = $fd
|
||||
zahl = $fe ; f<>rs Wrap
|
||||
; System:
|
||||
nmivek = $0318 ; NMI
|
||||
keybuffer= $034a
|
||||
pkydef = $100a ; Strings der F-Tasten
|
||||
texttop = $1210 ; Basic-Ende+1
|
||||
maxmem0 = $1212 ; Ende Bank 0
|
||||
basic = $12fd ; Basic-IRQ
|
||||
kernel_copyfont = $c027 ; Systemroutine, kopiert Font in VDC-RAM
|
||||
kernel_cls = $c142 ; Systemroutine, l<>scht Screen
|
||||
kernel_switchmode= $cd2e ; Systemroutine, switcht aktiven Monitor
|
||||
takt = $d030 ; 2 MHz ; register (**mark**)
|
||||
vdc = $d600 ; VDC
|
||||
reg = $d601
|
||||
conreg = $ff00 ; MMU-CR
|
||||
nmiend = $ff33 ; NMI-Ende
|
||||
primm = $ff7d ; Kernel
|
||||
open = $ffc0
|
||||
close = $ffc3
|
||||
chkin = $ffc6
|
||||
chkout = $ffc9
|
||||
clrchn = $ffcc
|
||||
basin = $ffcf
|
||||
basout = $ffd2
|
||||
798
examples/me/core.a
Normal file
798
examples/me/core.a
Normal file
@@ -0,0 +1,798 @@
|
||||
;ACME 0.91
|
||||
|
||||
!zone
|
||||
; Programm:
|
||||
mainloop
|
||||
; Cursor setzen:
|
||||
lda posy ; screeny = posy-spry
|
||||
sec
|
||||
sbc scry
|
||||
tay ; y in Y
|
||||
; ab hier X
|
||||
lda posx ; screenx = posx-scrx
|
||||
sec
|
||||
sbc scrx
|
||||
jsr crsrset ; set crsr
|
||||
; hier eigentliche Hauptroutine
|
||||
lda nwfrm ; new frame ?
|
||||
beq +
|
||||
jsr newframe ; yes = >
|
||||
+ lda updatewbi ; update flags?
|
||||
beq +
|
||||
jsr showwbi ; yes = >
|
||||
+ jsr getchar ; get CHARACTER
|
||||
tax ; & buffer
|
||||
and #%.##..... ; command ?
|
||||
beq + ; yes = >
|
||||
eor #%.##..... ; command ?
|
||||
beq + ; yes = >
|
||||
jsr chrout ; char out
|
||||
jmp mainloop
|
||||
+ jsr execom ; execute command
|
||||
jmp mainloop
|
||||
|
||||
!zone
|
||||
; Pseudo-Sub: (ESC uses jmp)
|
||||
F_esc clc ; 'ESC' on!
|
||||
lda clraktv
|
||||
ldx #hFlag_Escape
|
||||
jsr setflagdata
|
||||
- jsr getkey ; get KEY
|
||||
beq -
|
||||
sta byte ; & buffer
|
||||
clc ; 'ESC' off!
|
||||
lda clrinak
|
||||
ldx #hFlag_Escape
|
||||
jsr setflagdata
|
||||
ldx byte ; get byte
|
||||
txa ; & buffer
|
||||
eor #%.#...... ; a-z ?
|
||||
and #%.##.....
|
||||
bne + ; no = >
|
||||
txa ; get byte
|
||||
and #%...##### ; & short
|
||||
asl ; *2 &
|
||||
tax ; as index
|
||||
lda etab+1,x ; get Hi
|
||||
beq .no ; 0 = >
|
||||
sta .m+1 ; set
|
||||
lda etab,x ; get Lo
|
||||
sta .m ; set
|
||||
.m=*+1: jmp MODIFIED16 ; execute sequence
|
||||
.no rts ; nothing...
|
||||
+ txa ; get byte ( = FKey?)
|
||||
bpl .no ; out = >
|
||||
eor #%..#..... ; convert
|
||||
and #%.##..... ; test
|
||||
beq .no ; out = >
|
||||
txa ; get byte
|
||||
and #%...##### ; convert
|
||||
cmp #$05 ; test bottom border
|
||||
bcc .no ; too low = >
|
||||
cmp #$0d ; test upper border
|
||||
bcs .no ; too high = >
|
||||
; here: define f-keys !
|
||||
rts
|
||||
|
||||
!zone
|
||||
; NMI
|
||||
nmirtn lda #0 ; clear keybuffers
|
||||
sta ndx
|
||||
sta kyndx
|
||||
jmp nmiend
|
||||
|
||||
!zone
|
||||
; Subs:
|
||||
execom txa ; get & convert Byte
|
||||
bpl + ; (therefore strange
|
||||
eor #%#.#..... ; vectorlist)
|
||||
+ asl
|
||||
tax
|
||||
lda ctab+1,x ; get Hi
|
||||
beq noroutine ; 0 = >
|
||||
sta .m+1 ; and set
|
||||
lda ctab,x ; get Lo
|
||||
sta .m ; and set
|
||||
.m=*+1: jmp MODIFIED16 ; use command
|
||||
|
||||
noroutine rts ; not defined (fixme - could save a byte here)
|
||||
|
||||
!zone
|
||||
F_new jsr willblost
|
||||
beq noroutine
|
||||
jsr newtext
|
||||
jsr needline
|
||||
ldx #$0f ; use counter as "TRUE"
|
||||
stx nwfrm
|
||||
stx updatewbi
|
||||
stx unnamed
|
||||
- lda newname,x
|
||||
sta txtname,x
|
||||
dex
|
||||
bpl -
|
||||
inx
|
||||
stx changes
|
||||
rts
|
||||
|
||||
!zone
|
||||
newtext ldx #1 ; '1'
|
||||
stx scrx ; as X of screen,
|
||||
stx anfx ; blockstart, -end &
|
||||
stx endx ; crsr.
|
||||
stx posx
|
||||
stx scry ; ...as Y-Lo
|
||||
stx anfy
|
||||
stx endy
|
||||
stx posy
|
||||
dex ; '0'
|
||||
stx scry+1 ; ...as Y-Hi
|
||||
stx anfy+1
|
||||
stx endy+1
|
||||
stx posy+1
|
||||
stx zzbe ; no lines
|
||||
stx zzbe+1 ; used
|
||||
rts
|
||||
|
||||
!zone
|
||||
; 'key' ist der Kern, holt einen Code
|
||||
; ausm Puffer. 'char' wuerde, wenns ein
|
||||
; F-Key oder Accent ist, den Puffer
|
||||
; aendern und dann das erste Byte
|
||||
; abliefern. Hier nur das Standardprog:
|
||||
getchar jmp getkey
|
||||
.defrag ;{check fragjob}
|
||||
|
||||
getkey ;{check mousejob}
|
||||
;{check clockjob}
|
||||
ldx kyndx ; F-keys as standard
|
||||
beq .std
|
||||
ldy keyidx
|
||||
lda pkydef,y
|
||||
dec kyndx
|
||||
inc keyidx
|
||||
rts
|
||||
.std ldx ndx ; chars in buffer ?
|
||||
beq .defrag ; 0 = >
|
||||
sei ; else
|
||||
ldy keybuffer ; get first byte
|
||||
ldx #255 - 8 ; loop to shift other 9 chars down
|
||||
- lda keybuffer - 255 + 9,x
|
||||
sta keybuffer - 255 + 8,x
|
||||
inx ; (f7 to ff)
|
||||
bne -
|
||||
dec ndx ; dec number
|
||||
tya ; byte = >A
|
||||
stx keybuffer+9 ; clear lastbyte
|
||||
cli
|
||||
rts
|
||||
|
||||
!zone
|
||||
getvvek lda scry,x ; get y-Lo
|
||||
asl ; *2
|
||||
tay ; buffer
|
||||
lda scry+1,x ; get y-Hi
|
||||
rol ; *2 ( = clc)
|
||||
sta vvek+1 ; in Hi
|
||||
tya ; get Lo
|
||||
adc memin ; + BaseLo
|
||||
sta vvek ; = VectorLo
|
||||
lda vvek+1 ; get Hi
|
||||
adc memin+1 ; + BaseHi
|
||||
sta vvek+1 ; = VectorHi
|
||||
rts ; (VekVek)
|
||||
|
||||
; stellt Vektor auf Cursor-Y
|
||||
poslvek ldx #POS
|
||||
|
||||
; stellt Vektor auf Zeile
|
||||
!zone
|
||||
getlvek jsr getvvek ; get VekVek
|
||||
ldy #0 ; Y-Init
|
||||
lda (vvek),y ; get Lo-Byte
|
||||
sta lvek ; store
|
||||
iny ; inc vector
|
||||
lda (vvek),y ; get Hi-Byte
|
||||
sta lvek+1 ; store
|
||||
rts
|
||||
|
||||
!zone
|
||||
windowproof lda posx ;crsr-X
|
||||
cmp scrx ; screen(home)-X
|
||||
bcs + ; bigger = >
|
||||
sta scrx ; else set screen-X
|
||||
sta nwfrm ; and NewFrame
|
||||
bcc .UpDown
|
||||
+ sbc scrx ; difference
|
||||
cmp #scrcols ; cmp screenwidth
|
||||
bcc .UpDown ; ok = >
|
||||
lda posx ; else NewFrame,
|
||||
sta nwfrm
|
||||
sbc #scrcols-1 ; set screen-X
|
||||
sta scrx ; & store
|
||||
.UpDown lda scry+1 ; HiByte screen-
|
||||
cmp posy+1 ; Y and crsr-Y
|
||||
bcc crsrweiter ; shorter = >
|
||||
bne .set ; equal = >
|
||||
lda posy ; else cmp Lo-bytes
|
||||
cmp scry
|
||||
bcs crsrweiter ; shorter = >
|
||||
.set ldx posy ; get crsrpos as
|
||||
lda posy+1 ; new screenstart
|
||||
stx scry
|
||||
sta scry+1
|
||||
lda #TRUE ; NewFrame
|
||||
sta nwfrm
|
||||
rts
|
||||
|
||||
!zone
|
||||
crsrweiter sec ; for sbc
|
||||
lda posy ; calculate
|
||||
sbc scry ; Lo-difference
|
||||
tax ; in X
|
||||
lda posy+1 ; calculate
|
||||
sbc scry+1 ; Hi-difference
|
||||
bne + ; if Hi = 0
|
||||
cpx #scrlins ; & Lo ok,
|
||||
bcc ++ ; ready = >
|
||||
+ lda posy+1 ; else: copy Hibyte
|
||||
sta scry+1
|
||||
sec ; for sbc
|
||||
lda posy ; calculate & save
|
||||
sbc #scrlins-1 ; new Hibyte
|
||||
sta scry
|
||||
bcs + ; ggfs. = >
|
||||
dec scry+1 ; correct Hibyte
|
||||
+ lda #TRUE ; NewFrame
|
||||
sta nwfrm
|
||||
++ rts
|
||||
; Scrollroutines missing !
|
||||
|
||||
!zone
|
||||
; fuellt Speicher mit Zeilen
|
||||
fillmem lda #0 ; Keine Zeilen da
|
||||
sta zzan
|
||||
sta zzan+1
|
||||
ldx llen ; Zeilenlaenge
|
||||
inx ; + Info-Byte
|
||||
stx .m1 ; in SBC #$dummy
|
||||
lda maxmem0 ; holt MAX-MEM-0
|
||||
sta txts ; und nimmt es als
|
||||
lda maxmem0+1 ; Obergrenze !
|
||||
sta txts+1
|
||||
lda mod_id ; Holt ID-Adresse (Lo)
|
||||
tax ; sichern
|
||||
lsr ; Bit 0 ins Carry
|
||||
txa ; zurueck
|
||||
adc #6 ; +ID-2+C
|
||||
sta memin ; wird Vektorstart (Lo)
|
||||
lda mod_id+1 ; Hi-Byte
|
||||
adc #0 ; entsprechend
|
||||
sta memin+1 ; anpassen (Auto-CLC)
|
||||
; Carry wird addiert, damit Vektoren bei
|
||||
; einer GERADEN Adresse starten!
|
||||
lda memin ; Die VekVeks
|
||||
adc #2 ; werden ab dem
|
||||
sta vvek ; Vektorstart+2
|
||||
lda memin+1 ; abgelegt, da es
|
||||
adc #0 ; keine nullte Zeile
|
||||
sta vvek+1 ; gibt
|
||||
.Check lda txts ; TextstartLo
|
||||
sec
|
||||
.m1=*+1: sbc #MODIFIED8 ; -Zeilenl<6E>nge
|
||||
sta tmp1 ; wird gepuffert
|
||||
ldx txts+1
|
||||
bcs +
|
||||
dex
|
||||
+ stx tmp1+1
|
||||
cpx vvek+1 ; Vektorkollision ?
|
||||
bcc .NoLine ; Ja = > keine Zeile !
|
||||
bne .MakeLn ; Nein = > neue Zeile !
|
||||
ldx vvek ; Gleich: Lo-Bytes
|
||||
inx ; vergleichen
|
||||
cpx tmp1 ; Wieder: Kollision ?
|
||||
bcs .NoLine ; Ja = > keine Zeile !
|
||||
.MakeLn lda tmp1 ; Nein: dann temp als
|
||||
sta txts ; Textstart und in den
|
||||
ldy #0 ; Linevektor
|
||||
sta (vvek),y
|
||||
lda tmp1+1 ; dito, Highbyte
|
||||
sta txts+1
|
||||
iny
|
||||
sta (vvek),y
|
||||
inc vvek ; VekVek 2 Byte weiter
|
||||
+inc16 vvek
|
||||
inc zzan ; angelegte Zeilen
|
||||
bne .Check ; eins hoeher
|
||||
inc zzan+1
|
||||
jmp .Check
|
||||
.NoLine rts
|
||||
|
||||
!zone
|
||||
clearline lda #" " ; Space
|
||||
ldy llen ; Y auf Zeilenende
|
||||
- sta (lvek),y ; Space setzen
|
||||
dey ; zurueck
|
||||
bne - ; Infobyte ?
|
||||
tya ; Dann auf
|
||||
sta (lvek),y ; Null setzen
|
||||
dey ; Y auf $ff fuer
|
||||
sty nwfrm ; NewFrame
|
||||
sty changes ; Veraendert !
|
||||
; WordWrap sinnlos !
|
||||
rts
|
||||
|
||||
!zone
|
||||
; stellt Zeilen zur Verfuegung oder gibt Fehlermeldung
|
||||
needline +cmp16bit ZZA, ZZB ; vergleichen
|
||||
beq + ; Wenn gleich, wirds gesetzte Carry 'failure'
|
||||
+inc16 zzbe ; sonst: Zahl der genutzten Zeilen hoeher
|
||||
ldx #ZZB
|
||||
stx changes ; Veraendert !
|
||||
jsr getlvek ; Holt Vektor
|
||||
jsr clearline ; und leert Zeile
|
||||
clc ; 'success'
|
||||
; EIGENTLICH ist das Carrybit hier schon
|
||||
; durch die beiden Subs gel<65>scht...
|
||||
+ rts
|
||||
|
||||
cmp16bit lda scry+1,x ; Hi-Bytes vergleichen
|
||||
cmp scry+1,y
|
||||
bne + ; wenn gleich,
|
||||
lda scry,x ; Lo-Bytes vergleichen
|
||||
cmp scry,y
|
||||
+ rts
|
||||
|
||||
F_gcr inc posx
|
||||
jmp proofpos
|
||||
|
||||
F_gcl dec posx
|
||||
jmp proofpos
|
||||
|
||||
F_gcu ldx posy
|
||||
bne +
|
||||
dec posy+1
|
||||
+ dec posy
|
||||
jmp proofpos
|
||||
|
||||
F_gcd +inc16 posy
|
||||
|
||||
!zone
|
||||
proofpos ldx posx ; CRSR-X
|
||||
beq .jBack ; Null = >
|
||||
dex ; verringern und mit
|
||||
cpx llen ; Laenge vergl.
|
||||
bcs jump ; zu weit rechts = >
|
||||
lda posy+1 ; CRSR-Y (Hi)
|
||||
bmi firstline ; >32K = > 1. Zeile = >
|
||||
ora posy ; ODERt Low-Byte
|
||||
beq firstline ; = 0 = > 1. Zeile = >
|
||||
+cmp16bit ZZB, POS ; vergleichen
|
||||
bcc F_geot ; CRSR zu weit = >
|
||||
jmp windowproof ; okay
|
||||
|
||||
.jBack ldx llen ; Zeilenlaenge wird
|
||||
stx posx ; neue Position & hoch
|
||||
jsr F_gcu
|
||||
jsr poslvek ; LineVek holen
|
||||
jsr findend ; Ende suchen
|
||||
iny ; dahintersetzen
|
||||
sty posx
|
||||
jmp proofpos
|
||||
|
||||
jump jsr newline ; naechste Zeile
|
||||
bcs + ; CRSR zu weit,
|
||||
jsr needline ; Zeile anfordern
|
||||
bcc + ; Bei Fehlschlag
|
||||
jsr memfull ; Warnung zeigen
|
||||
+ jmp proofpos
|
||||
|
||||
!zone
|
||||
firstline ldx #1 ; CRSR in erste Zeile
|
||||
stx posy
|
||||
dex
|
||||
stx posy+1
|
||||
jmp windowproof
|
||||
|
||||
F_geot +cp16 zzbe, posy; CRSR in letzte Zeile
|
||||
jmp windowproof
|
||||
|
||||
!zone
|
||||
newline lda #1 ; X-Pos : = 1 & Y += 1
|
||||
sta posx
|
||||
+inc16 posy
|
||||
+cmp16bit ZZB, POS ; vergleichen
|
||||
rts
|
||||
|
||||
!zone
|
||||
F_cs lda #1 ; CRSR 2 next linestart
|
||||
sta posx
|
||||
+inc16 posy
|
||||
jmp proofpos
|
||||
|
||||
!zone
|
||||
chrout stx byte ; sichert Zeichen
|
||||
jsr poslvek ; LineVek
|
||||
ldy esca ; Autoinsert ?
|
||||
beq + ; ggfs. kein
|
||||
jsr insert1 ; insert
|
||||
+ ldy posx ; Versatz
|
||||
lda byte ; Akku holen
|
||||
sta (lvek),y ; und setzen
|
||||
jsr poswrap ; Wrap ?
|
||||
lda #TRUE ; NewFrame fordern
|
||||
sta nwfrm
|
||||
sta changes ; Veraendert !
|
||||
jmp F_gcr
|
||||
|
||||
!zone
|
||||
F_insert jsr poslvek ; LineVek
|
||||
jsr insert1 ; insert
|
||||
jsr poswrap ; Wrap ?
|
||||
rts ; fixme - could save a byte here
|
||||
|
||||
!zone
|
||||
insert1 ldy scrx,x ; X-Wert holen & in
|
||||
sty .mod ; Immediate
|
||||
ldy lvek+1 ; Quell-Vektor =
|
||||
ldx lvek ; aktueller Vektor-1
|
||||
bne +
|
||||
dey
|
||||
+ dex
|
||||
stx tmp1
|
||||
sty tmp1+1
|
||||
ldy llen ; Shiftstart LineEnd
|
||||
-
|
||||
.mod=*+1: cpy #MODIFIED8 ; X
|
||||
beq + ; Ende = >
|
||||
lda (tmp1),y ; Zeichen holen
|
||||
sta (lvek),y ; und shiften
|
||||
dey ; neue Pos
|
||||
jmp -
|
||||
+ lda #" " ; 'Space' an
|
||||
sta (lvek),y ; Pos setzen
|
||||
sta nwfrm ; NewFrame fordern
|
||||
sta changes ; Veraendert !
|
||||
rts
|
||||
|
||||
!zone
|
||||
F_dcl jsr F_gcl
|
||||
F_dcr jsr poslvek ; LineVek
|
||||
jsr delchr1 ; Delete
|
||||
jsr poswrap ; Wrap ?
|
||||
jmp proofpos
|
||||
|
||||
!zone
|
||||
delchr1 ldy scrx,x ; X-Wert in Immediate
|
||||
sty .m
|
||||
ldx lvek ; Zielvektor = aktueller
|
||||
ldy lvek+1 ; Vektor+1
|
||||
inx
|
||||
bne +
|
||||
iny
|
||||
+ stx tmp1
|
||||
sty tmp1+1
|
||||
.m=*+1: ldy #MODIFIED8 ; X
|
||||
- cpy llen ; Zeilenende ?
|
||||
beq + ; Dann = >
|
||||
lda (tmp1),y ; Zeichen holen
|
||||
sta (lvek),y ; und shiften
|
||||
iny ; neue Pos
|
||||
jmp -
|
||||
+ lda #" " ; Space an letzte
|
||||
sta (lvek),y ; Pos setzen
|
||||
lda #TRUE ; NewFrame fordern
|
||||
sta nwfrm
|
||||
sta changes ; Veraendert !
|
||||
rts
|
||||
|
||||
!zone
|
||||
; Einsprung: X = StartIndex, Y = EndIndex
|
||||
; Bewegt Zeilenbloecke: X bis Y-1 werden nach X+1 bis Y geschoben. Danach
|
||||
; liegt die Endzeile in der Startzeile
|
||||
rollfwd jsr howmany ; Zeilenanzahl ?
|
||||
beq ++ ; ggfs Abbruch !
|
||||
tya ; Y in X
|
||||
tax
|
||||
jsr getlvek ; lvek in lvek puffern
|
||||
sec ; Quellvektor = Vektor-2
|
||||
lda vvek
|
||||
sbc #2
|
||||
sta tmp1
|
||||
lda vvek+1
|
||||
sbc #0
|
||||
sta tmp1+1
|
||||
ldy #2 ; Versatz 2
|
||||
- tya ; Y pruefen
|
||||
bne + ; ggfs
|
||||
dec tmp1+1 ; Page sichern
|
||||
dec vvek+1
|
||||
+ dey ; Versatz runter
|
||||
lda (tmp1),y ; High-Byte oben setzen
|
||||
sta (vvek),y
|
||||
dey ; Versatz runter
|
||||
lda (tmp1),y ; Low-Byte oben setzen
|
||||
sta (vvek),y
|
||||
inc tmpy ; Anzahl der Shifts
|
||||
bne - ; pruefen, ggfs loop
|
||||
inc tmpy+1
|
||||
bne -
|
||||
lda lvek ; alten Vektor holen
|
||||
sta (tmp1),y ; und in letzte
|
||||
iny ; Position setzen
|
||||
lda lvek+1
|
||||
sta (tmp1),y
|
||||
++ lda #TRUE ; NewFrame fordern
|
||||
sta nwfrm
|
||||
sta changes ; Veraendert !
|
||||
rts
|
||||
|
||||
!zone
|
||||
; Einsprung: X = StartIndex, Y = Endzeile
|
||||
; Bewegt Zeilenbloecke: X+1 bis Y werden nach X bis Y-1 geschoben. Danach
|
||||
; liegt die Startzeile in der Endzeile !
|
||||
rollrwd jsr howmany ; Zeilenanzahl ?
|
||||
beq ++ ; ggfs Abbruch !
|
||||
jsr getlvek ; lvek in lvek puffern
|
||||
clc ; Quellvektor = Vektor+2
|
||||
lda vvek
|
||||
adc #2
|
||||
sta tmp1
|
||||
lda vvek+1
|
||||
adc #0
|
||||
sta tmp1+1
|
||||
ldy #0 ; Versatz 0
|
||||
- lda (tmp1),y ; Hi-Byte unten setzen
|
||||
sta (vvek),y
|
||||
iny ; weiter
|
||||
lda (tmp1),y ; Lo-Byte unten setzen
|
||||
sta (vvek),y
|
||||
iny ; weiter
|
||||
bne + ; Page sichern
|
||||
inc tmp1+1
|
||||
inc vvek+1
|
||||
+ inc tmpy ; Anzahl Shifts
|
||||
bne - ; pruefen, ggfs loop
|
||||
inc tmpy+1
|
||||
bne -
|
||||
lda lvek ; alten Vektor an die
|
||||
sta (vvek),y ; letzte Pos setzen
|
||||
iny
|
||||
lda lvek+1
|
||||
sta (vvek),y
|
||||
++ lda #TRUE ; NewFrame fordern
|
||||
sta nwfrm
|
||||
sta changes ; Veraendert !
|
||||
rts
|
||||
|
||||
!zone
|
||||
howmany jsr cmp16bit ; Sicherheit
|
||||
bcs + ; ggfs Abbruch = >
|
||||
sec ; Negativ, um INC statt DEC nutzen zu k<>nnen
|
||||
lda scry,x
|
||||
sbc scry,y
|
||||
sta tmpy
|
||||
lda scry+1,x
|
||||
sbc scry+1,y
|
||||
sta tmpy+1
|
||||
rts
|
||||
+ lda #0 ; Zeilen
|
||||
rts
|
||||
|
||||
!zone
|
||||
movx2y lda scrx,x ; Copy X-indexed Werte in Y-indexed Variablen
|
||||
sta scrx,y
|
||||
lda scry,x
|
||||
sta scry,y
|
||||
lda scry+1,x
|
||||
sta scry+1,y
|
||||
rts
|
||||
|
||||
ESC_at rts ; fixme - could save one byte here
|
||||
|
||||
ESC_a lda #TRUE ; Set AutoInsert
|
||||
sta esca
|
||||
sta updatewbi ; Update fordern
|
||||
rts
|
||||
|
||||
ESC_b ldx #POS ; BlockEnd: = Cursorposition
|
||||
ldy #END
|
||||
jsr movx2y
|
||||
|
||||
!zone
|
||||
; Block legal ? Vertauscht ggfs Zeiger
|
||||
nblck +cmp16bit ANF, END ; Blockstart und -Ende vergleichen
|
||||
bcc ++ ; anf<end: ok
|
||||
bne + ; anf>end: not ok
|
||||
lda scrx,y ; Bei Gleichheit noch
|
||||
cmp scrx,x ; X pruefen
|
||||
bcs ++ ; end> = anf: ok
|
||||
+ ldy #TMP ; (Anf) in Temp
|
||||
jsr movx2y
|
||||
ldx #END ; Ende in Anf
|
||||
ldy #ANF
|
||||
jsr movx2y
|
||||
ldx #TMP ; Temp in Ende
|
||||
ldy #END
|
||||
jsr movx2y
|
||||
++ lda #TRUE ; NewFrame fordern
|
||||
sta nwfrm ; (Blockanzeige)
|
||||
sta blockflag ; Block ein
|
||||
rts
|
||||
|
||||
!zone
|
||||
ESC_c ldx #FALSE ; Clear AutoInsert
|
||||
stx esca
|
||||
dex ; Update fordern
|
||||
stx updatewbi
|
||||
rts
|
||||
|
||||
ESC_d ldx #POS ; Start: Cursorposition
|
||||
jsr delline ; Zeile weg
|
||||
jmp poswrap ; und wrap
|
||||
|
||||
!zone
|
||||
delline ldy #ZZB ; Ende: LastLine
|
||||
jsr rollrwd ; runterrollen
|
||||
lda zzbe ; Anzahl der benutzten Zeilen runter
|
||||
bne +
|
||||
dec zzbe+1
|
||||
+ dec zzbe
|
||||
bne + ; Low = 0 ?
|
||||
lda zzbe+1 ; Dann High pruefen und ggfs Zeile fordern
|
||||
bne +
|
||||
jsr needline
|
||||
+ jmp proofpos
|
||||
|
||||
!zone
|
||||
ESC_g ldx #FALSE ; Beep On
|
||||
stx beep
|
||||
dex ; Update fordern
|
||||
stx updatewbi
|
||||
rts
|
||||
|
||||
ESC_h lda #TRUE ; Beep Off
|
||||
sta beep
|
||||
sta updatewbi ; Update fordern
|
||||
rts
|
||||
|
||||
!zone
|
||||
ESC_i jsr needline ; Zeile fordern
|
||||
+bcs memfull ; bei Fehlschlag Warnung = >
|
||||
ldx #POS ; Start: Cursorposition
|
||||
ldy #ZZB ; Ende: LastLine
|
||||
jsr rollfwd ; raufrollen
|
||||
rts ; fixme - could save a byte here
|
||||
|
||||
!zone
|
||||
F_gsol
|
||||
ESC_j lda #1 ; Cursor-X: = 1
|
||||
sta posx
|
||||
jmp windowproof
|
||||
|
||||
F_geol
|
||||
ESC_k jsr poslvek ; LineVek
|
||||
jsr findend ; sucht letztes Byte, dahinter steht dann Cursor
|
||||
iny
|
||||
sty posx
|
||||
jmp proofpos
|
||||
|
||||
ESC_o lda blockflag ; toggle Flag
|
||||
eor #$ff
|
||||
sta blockflag
|
||||
rts
|
||||
|
||||
ESC_p
|
||||
ESC_q rts ; fixme - could save a byte here
|
||||
|
||||
ESC_t ldx #POS ; Blockstart = Cursorposition
|
||||
ldy #ANF
|
||||
jsr movx2y
|
||||
jmp nblck ; legal ?
|
||||
|
||||
F_home ldx scrx ; Normal HOME only,
|
||||
ldy scry ; if CRSR not there
|
||||
lda scry+1
|
||||
cpx posx ; Otherwise ScreenUp
|
||||
bne scrnhome
|
||||
cpy posy
|
||||
bne scrnhome
|
||||
cmp posy+1
|
||||
bne scrnhome
|
||||
|
||||
!zone
|
||||
F_scrnu lda posy ; Displaystart =
|
||||
sec ; Displaystart
|
||||
sbc #scrlins ; - Zeilenzahl
|
||||
sta posy
|
||||
bcs +
|
||||
dec posy+1
|
||||
+ lda #TRUE ; NewFrame fordern
|
||||
sta nwfrm
|
||||
jmp proofpos
|
||||
|
||||
!zone
|
||||
scrnhome stx posx ; Cursor: = Display
|
||||
sty posy
|
||||
sta posy+1
|
||||
jmp proofpos
|
||||
|
||||
F_ahome clc ; errechnet Werte
|
||||
lda scry ; fuer antih1
|
||||
adc #scrlins-1 ; in A, X, Y
|
||||
tax
|
||||
lda scry+1
|
||||
adc #0
|
||||
tay
|
||||
lda scrx ; CRSR dort ?
|
||||
cmp posx
|
||||
bne antih1
|
||||
cpx posy ; Nein = > dorthin
|
||||
bne antih1
|
||||
cpy posy+1 ; Ja = > ScreenDown !
|
||||
bne antih1
|
||||
|
||||
!zone
|
||||
F_scrnd lda posy ; One screen down
|
||||
clc
|
||||
adc #scrlins
|
||||
sta posy
|
||||
bcc +
|
||||
inc posy+1
|
||||
+ lda #TRUE ; NewFrame fordern
|
||||
sta nwfrm
|
||||
jmp proofpos
|
||||
|
||||
!zone
|
||||
antih1 sta posx ; Cursor: = DisplayEnd
|
||||
stx posy
|
||||
sty posy+1
|
||||
jmp proofpos
|
||||
|
||||
F_gsot ldx #1 ; X = Y = 1
|
||||
stx posx
|
||||
stx posy
|
||||
stx nwfrm ; NewFrame fordern
|
||||
dex ; Y-Hi: = 0
|
||||
stx posy+1
|
||||
jmp proofpos
|
||||
|
||||
!zone
|
||||
handleid ldx #7 ; 8 Byte Kennung
|
||||
-
|
||||
mod_id=*+1: lda MODIFIED16,x; Schleife, um evtl. vorhandenen Text zu
|
||||
cmp idtext,x
|
||||
bne makeid ; erkennen & zu reaktivieren
|
||||
dex
|
||||
bpl -
|
||||
clc ; 'OldText'
|
||||
rts
|
||||
|
||||
makeid lda texttop ; Neue ID wird ans Basic-Ende gesetzt
|
||||
sta mod_id
|
||||
sta .m1
|
||||
lda texttop+1
|
||||
sta mod_id+1
|
||||
sta .m1+1
|
||||
ldx #7
|
||||
- lda idtext,x
|
||||
.m1=*+1: sta MODIFIED16,x
|
||||
dex
|
||||
bpl -
|
||||
sec ; 'NewText'
|
||||
rts
|
||||
|
||||
F_cr jsr F_lfeed
|
||||
jmp jump
|
||||
|
||||
F_c :F_f :F_ffeed :F_dir
|
||||
F_fbox :F_hlp :F_bell :F_tab
|
||||
F_text :F_middle :F_graphic
|
||||
F_fn :F_ff :F_un :F_uf :F_rn :F_rf
|
||||
F_sf :F_sk :F_su :F_st :F_sl
|
||||
F_gld :F_glu :F_gad :F_gau :F_gpd :F_gpu
|
||||
F_gtr :F_gtl :F_gwr :F_gwl
|
||||
F_bttnn :F_bttnf :F_find :F_print :F_mode :F_dword
|
||||
F_cut :F_copy :F_paste :F_move
|
||||
F_fmtl :F_fmtr :F_fmtm :F_fmtb
|
||||
|
||||
rts ; (yet) missing
|
||||
111
examples/me/cursor.a
Normal file
111
examples/me/cursor.a
Normal file
@@ -0,0 +1,111 @@
|
||||
;ACME 0.91
|
||||
|
||||
; ab hier liegt die Cursorsteuerung
|
||||
; A = screenx, Y = screeny
|
||||
!zone
|
||||
crsrset sta .m ; buffer x
|
||||
iny ; adjust height
|
||||
iny
|
||||
iny
|
||||
sty .n ; buffer y
|
||||
jsr crsroff
|
||||
lda #0 ; clear Hi
|
||||
sta vtemp+1
|
||||
.n=*+1: lda #MODIFIED8 ; y
|
||||
asl ; *2
|
||||
asl ; *4
|
||||
rol vtemp+1
|
||||
asl ; *8
|
||||
rol vtemp+1
|
||||
asl ; *16
|
||||
rol vtemp+1
|
||||
sta vtemp ; stash Lo
|
||||
ldy vtemp+1 ; copy Hi
|
||||
sty vtemp+2
|
||||
asl ; *32
|
||||
rol vtemp+2
|
||||
asl ; *64
|
||||
rol vtemp+2
|
||||
adc vtemp ; + 16er-Lo
|
||||
sta vtemp ; 80er-Lo in vtemp
|
||||
bcc + ; page
|
||||
inc vtemp+1
|
||||
clc
|
||||
+
|
||||
.m=*+1: adc #MODIFIED8 ; x
|
||||
sta vtemp ; store Lo
|
||||
lda vtemp+1 ; get 16er-Hi
|
||||
adc vtemp+2 ; add 64er-Hi
|
||||
adc #attrhi ; add base
|
||||
sta vtemp+1 ; store Hi
|
||||
|
||||
!zone
|
||||
crsron lda conreg ; buffert CR
|
||||
sta .m
|
||||
+bank15
|
||||
jsr vpntcrsr ; set address
|
||||
- bit vdc ; get ready
|
||||
bpl -
|
||||
lda reg ; get attribute
|
||||
sta tcolor ; buffer it
|
||||
jsr vpntcrsr ; set address
|
||||
lda clrcrsr ; get crsr
|
||||
- bit vdc ; get ready
|
||||
bpl -
|
||||
sta reg ; set crsr
|
||||
.m=*+1: lda #MODIFIED8 ; bank
|
||||
sta conreg ; restore CR
|
||||
rts
|
||||
|
||||
!zone
|
||||
crsroff lda conreg ; buffer CR
|
||||
sta .m
|
||||
+bank15
|
||||
jsr vpntcrsr ; set address
|
||||
lda tcolor ; get attribute
|
||||
- bit vdc ; get ready
|
||||
bpl -
|
||||
sta reg ; set attribute
|
||||
.m=*+1: lda #MODIFIED8 ; bank
|
||||
sta conreg ; restore CR
|
||||
rts
|
||||
|
||||
; push data
|
||||
!zone
|
||||
crsrnew ldx crsrheap ; get stackpointer
|
||||
lda vtemp ; get low
|
||||
sta crsrheap,x ; push
|
||||
lda vtemp+1 ; get high
|
||||
sta crsrheap+1,x; push
|
||||
inx ; inc stackpointer
|
||||
inx
|
||||
stx crsrheap ; set stackpointer
|
||||
jsr crsroff
|
||||
|
||||
!zone
|
||||
crsrhide ldx #$3f ; place cursor
|
||||
stx vtemp+1 ; outside visible
|
||||
ldx #$ff ; area
|
||||
stx vtemp
|
||||
rts
|
||||
|
||||
!zone
|
||||
crsrold ldx crsrheap ; get stackpointer
|
||||
dex ; previous entry !
|
||||
dex
|
||||
lda crsrheap,x ; get lo
|
||||
sta vtemp ; set lo
|
||||
lda crsrheap+1,x; get hi
|
||||
sta vtemp+1 ; set hi
|
||||
stx crsrheap ; set stackpointer
|
||||
jmp crsron
|
||||
|
||||
!zone
|
||||
crsrinit ldx #1 ; init cursorstack
|
||||
stx crsrheap
|
||||
jmp crsrhide ; and hide cursor
|
||||
|
||||
crsrheap !fill 33, 33
|
||||
|
||||
vpntcrsr +ldax vtemp
|
||||
jmp ramaccess ; set vdc
|
||||
286
examples/me/file.a
Normal file
286
examples/me/file.a
Normal file
@@ -0,0 +1,286 @@
|
||||
;ACME 0.91
|
||||
|
||||
; ChangesNotSaved.Save?
|
||||
!zone
|
||||
willblost ldx changes
|
||||
bne +
|
||||
inx
|
||||
rts ; return with X=1 ("Changes safe, go on")
|
||||
|
||||
+ jsr crsrnew
|
||||
ldx #hWindow_DCS
|
||||
stx menunr
|
||||
jsr makewin
|
||||
ldy #$0b ; y-pos of cursor in window
|
||||
lda #$32 ; x-pos
|
||||
jsr crsrset
|
||||
wblchoice jsr getchar
|
||||
cmp #Char_DEL
|
||||
beq wblchoiced
|
||||
cmp #Char_STOP
|
||||
beq wblchoicec
|
||||
cmp #Char_RETURN
|
||||
bne wblchoice
|
||||
jsr pullscr
|
||||
jsr crsrold
|
||||
jsr F_saveas
|
||||
jmp willblost
|
||||
|
||||
wblchoiced jsr pullscr
|
||||
jsr crsrold
|
||||
ldx #FALSE
|
||||
stx changes
|
||||
ldx #2
|
||||
rts ; return with X=2 ("Changes discarded, go on")
|
||||
|
||||
wblchoicec jsr pullscr
|
||||
jsr crsrold
|
||||
ldx #0
|
||||
rts ; return with X=1 ("Cancel operation !")
|
||||
|
||||
eotflag !byte 0 ; End-Flag
|
||||
|
||||
!zone
|
||||
F_mergeas lda #$1f ; get Mergename
|
||||
sta loadflag ; Mode MERGE
|
||||
jmp +
|
||||
|
||||
noload rts ; fixme - could save a byte here
|
||||
|
||||
F_loadas jsr willblost ; Changes saved ?
|
||||
beq noload
|
||||
lda #0 ; Mode LOAD
|
||||
sta loadflag
|
||||
lda #$3f ; get LOADname
|
||||
+ jsr rename
|
||||
bne load ; ggfs Abbruch
|
||||
rts
|
||||
|
||||
!zone
|
||||
loadalien lda loadflag
|
||||
bne loadfirst
|
||||
jmp noheader
|
||||
load lda conreg ; Bank sichern
|
||||
pha
|
||||
jsr crsrnew ; new copy (hidden)
|
||||
ldx #hWindow_Load
|
||||
stx menunr
|
||||
jsr makewin
|
||||
jsr copypara ; Parameter setzen
|
||||
lda #"r" ; Lesemodus
|
||||
sta dosmode
|
||||
+bank15
|
||||
jsr open ; Open File
|
||||
ldx #lf ; File: = Input
|
||||
jsr chkin
|
||||
ldy #$0f ; Header pruefen
|
||||
- jsr basin
|
||||
cmp idfile,y
|
||||
bne loadalien
|
||||
dey
|
||||
bpl -
|
||||
ldy #$0f ; Namen holen
|
||||
- jsr basin
|
||||
sta dosname,y
|
||||
dey
|
||||
bpl -
|
||||
lda loadflag ; Bei LOAD
|
||||
bne loadfirst ; Name kopieren,
|
||||
sta unnamed ; (clear Flag)
|
||||
ldy #$0f
|
||||
- lda dosname,y
|
||||
sta txtname,y
|
||||
sta lodname,y
|
||||
dey
|
||||
bpl -
|
||||
sty updatewbi ; Update verlangen,
|
||||
jsr newtext ; Defaultwerte
|
||||
loadfirst ldy #FALSE ; Pufferstart
|
||||
sty eotflag ; init Flag
|
||||
|
||||
!zone
|
||||
loadline +xbank15
|
||||
- iny ; Eins weiter
|
||||
lda #" " ; get Space
|
||||
ldx status
|
||||
bne + ; ggfs
|
||||
jsr basin ; get Byte
|
||||
+ sta linebuf,y ; und setzen
|
||||
cpy llen
|
||||
bne -
|
||||
ldy #1 ; Neustart
|
||||
- lda linebuf,y
|
||||
cmp #Char_RETURN
|
||||
beq ++
|
||||
cmp #"-"
|
||||
bne +
|
||||
sty linebuf ; Dann Pos merken
|
||||
+ cmp #" "
|
||||
bne +
|
||||
sty linebuf ; Dann Pos merken
|
||||
+ iny ; weiter
|
||||
cpy llen
|
||||
bne -
|
||||
lda linebuf,y ; LineEnd = Space ?
|
||||
cmp #" " ; Dann Grenze: = Y &
|
||||
bne +
|
||||
sty linebuf
|
||||
lda status
|
||||
beq + ; ggfs setflag
|
||||
sta eotflag
|
||||
+ ldy linebuf ; get Grenze
|
||||
bne +
|
||||
ldy llen
|
||||
dey
|
||||
++ sty linebuf
|
||||
+ +xram0
|
||||
jsr needline ; fordert Zeile
|
||||
bcs nomemleft ; ggfs Abbruch
|
||||
ldy linebuf ; copy buffer2line
|
||||
- lda linebuf,y
|
||||
sta (lvek),y
|
||||
dey
|
||||
bne -
|
||||
lda eotflag ; Ende ?
|
||||
bne endoffile
|
||||
ldx linebuf ; shift buffer
|
||||
- cpx llen ; fertig ?
|
||||
beq loadline ; Dann lesen !
|
||||
inx
|
||||
iny
|
||||
lda linebuf,x
|
||||
sta linebuf,y
|
||||
jmp -
|
||||
|
||||
nomemleft jsr memfull ; Warnung
|
||||
endoffile +bank15
|
||||
lda loadflag
|
||||
sta changes
|
||||
noheader jsr clrchn ; Standard
|
||||
lda #lf ; Close File
|
||||
jsr close
|
||||
jsr pullscr ; Win weg
|
||||
jsr crsrold ; restore cursor
|
||||
pla ; alte Bank
|
||||
sta conreg
|
||||
rts
|
||||
|
||||
!zone
|
||||
nosave rts ; Abbruch (fixme - could save a byte here)
|
||||
|
||||
F_saveas jsr F_rnmtxt ; get Textname
|
||||
beq nosave ; ggfs Abbruch
|
||||
lda #FALSE ; Name vorhanden
|
||||
sta unnamed
|
||||
F_save lda unnamed ; Name ?
|
||||
bne F_saveas ; ggfs holen
|
||||
ldy #$0f ; proof "?"
|
||||
- lda txtname,y
|
||||
cmp #"?"
|
||||
beq F_saveas
|
||||
cmp #"*"
|
||||
beq F_saveas
|
||||
cmp #","
|
||||
beq F_saveas
|
||||
cmp #":"
|
||||
beq F_saveas
|
||||
sta dosname,y
|
||||
dey
|
||||
bpl -
|
||||
lda #"w" ; Schreibmodus
|
||||
sta dosmode
|
||||
lda conreg ; Bank sichern
|
||||
pha
|
||||
+bank15
|
||||
jsr crsrnew ; new copy (hidden)
|
||||
ldx #hWindow_Save; Save-Win
|
||||
stx menunr
|
||||
jsr makewin
|
||||
jsr copykill ; Killparameter
|
||||
jsr open ; Open CmdChannel
|
||||
lda killpara+1 ; (Scratch)
|
||||
jsr close ; Close CC
|
||||
jsr copypara ; Dateiparameter
|
||||
jsr open ; Open Outputfile
|
||||
ldx #lf
|
||||
jsr chkout
|
||||
ldy #$0f ; Sendet Header
|
||||
- lda idfile,y
|
||||
jsr basout
|
||||
dey
|
||||
bpl -
|
||||
ldy #$0f ; Sendet Name
|
||||
- lda txtname,y
|
||||
jsr basout
|
||||
dey
|
||||
bpl -
|
||||
iny ; Y: = 0, tmpy wird fuers
|
||||
sty tmpy+1 ; Speichern init.
|
||||
tya ; A: = 0
|
||||
iny ; Y: = 1
|
||||
sty tmpy
|
||||
sec ; errechnet negativen
|
||||
sbc zzbe ; Zeilenzaehler (tmp2)
|
||||
sta tmp2
|
||||
lda #0
|
||||
sbc zzbe+1
|
||||
sta tmp2+1
|
||||
-- +xram0 ; volles RAM
|
||||
ldx #1 ; mind. 1 Byte/Zeile
|
||||
stx linebuf
|
||||
ldx #TMP
|
||||
jsr getlvek ; LineVek
|
||||
ldy #1 ; Versatz: = 1
|
||||
- lda (lvek),y ; Byte in Puffer
|
||||
cmp #" "
|
||||
beq +
|
||||
sty linebuf ; Pos sichern
|
||||
+ sta linebuf,y
|
||||
iny
|
||||
cpy llen
|
||||
bne -
|
||||
ldx linebuf
|
||||
lda linebuf,x ; letztes Byte
|
||||
cmp #Char_RETURN
|
||||
beq +
|
||||
cmp #"-"
|
||||
beq +
|
||||
cmp #" "
|
||||
beq +
|
||||
inx ; Dann Space hinter
|
||||
lda #" " ; die Zeile
|
||||
sta linebuf,x
|
||||
+ stx .m ; Ende speichern
|
||||
+xbank15
|
||||
- inx ; X = 1
|
||||
lda linebuf,x ; Zeichen senden
|
||||
jsr basout
|
||||
.m=*+1: cpx #MODIFIED8 ; L<>nge
|
||||
bne - ; alle ?
|
||||
+inc16 tmpy ; tmpy += 1
|
||||
inc tmp2 ; zaehler += 1
|
||||
bne --
|
||||
inc tmp2+1
|
||||
bne --
|
||||
jsr clrchn ; Standardkanaele
|
||||
lda #lf
|
||||
jsr close ; Close File
|
||||
jsr pullscr ; Win weg
|
||||
jsr crsrold ; restore cursor
|
||||
pla ; alte Bank
|
||||
sta conreg
|
||||
lda #FALSE ; Changes saved !
|
||||
sta changes
|
||||
rts
|
||||
|
||||
!zone
|
||||
copykill ldy #$0b ; Scratchparameter
|
||||
+bit16 ; BIT-Trick !
|
||||
copypara ldy #$05 ; Fileparameter
|
||||
ldx #5 ; 6 Bytes
|
||||
- lda filepara,y ; ins System
|
||||
sta fnlen,x
|
||||
dey
|
||||
dex
|
||||
bpl -
|
||||
rts
|
||||
72
examples/me/macros.a
Normal file
72
examples/me/macros.a
Normal file
@@ -0,0 +1,72 @@
|
||||
;ACME 0.91
|
||||
|
||||
!macro cmp16bit .data1, .data2 {
|
||||
ldx #.data1
|
||||
ldy #.data2
|
||||
jsr cmp16bit
|
||||
}
|
||||
a = 0
|
||||
x = 1
|
||||
y = 2
|
||||
|
||||
!macro bank .r, .v {
|
||||
!if .r = a {
|
||||
lda #.v
|
||||
sta conreg
|
||||
}
|
||||
!if .r = x {
|
||||
ldx #.v
|
||||
stx conreg
|
||||
}
|
||||
!if .r = y {
|
||||
ldy #.v
|
||||
sty conreg
|
||||
}
|
||||
}
|
||||
|
||||
CR_BANK15 = 0
|
||||
CR_RAM0_IO = $3e
|
||||
CR_RAM0 = $3f
|
||||
|
||||
!macro bank15 {
|
||||
+bank a, CR_BANK15
|
||||
}
|
||||
|
||||
!macro xbank15 {
|
||||
+bank x, CR_BANK15
|
||||
}
|
||||
|
||||
!macro ybank15 {
|
||||
+bank y, CR_BANK15
|
||||
}
|
||||
|
||||
!macro ram0io {
|
||||
+bank a, CR_RAM0_IO
|
||||
}
|
||||
|
||||
!macro yram0io {
|
||||
+bank y, CR_RAM0_IO
|
||||
}
|
||||
|
||||
!macro xram0 {
|
||||
+bank x, CR_RAM0
|
||||
}
|
||||
|
||||
!macro inc16x .a {
|
||||
inc .a,x
|
||||
bne +
|
||||
inc .a+1,x
|
||||
+
|
||||
}
|
||||
|
||||
!macro ldax .a {
|
||||
lda .a+1
|
||||
ldx .a
|
||||
}
|
||||
|
||||
!macro cp16 .s, .t {
|
||||
ldx .s
|
||||
lda .s+1
|
||||
stx .t
|
||||
sta .t+1
|
||||
}
|
||||
1439
examples/me/out.a
Normal file
1439
examples/me/out.a
Normal file
File diff suppressed because it is too large
Load Diff
BIN
examples/me/tables.bin
Normal file
BIN
examples/me/tables.bin
Normal file
Binary file not shown.
124
examples/me/vars.a
Normal file
124
examples/me/vars.a
Normal file
@@ -0,0 +1,124 @@
|
||||
;ACME 0.91
|
||||
|
||||
; Vermerk:
|
||||
!text "MacEdit was written by Mac Bacon in 1994-97."
|
||||
!text " This is Freeware !"
|
||||
|
||||
; Variablen:
|
||||
stck !byte 0 ; Stackbuffer
|
||||
nmibuf !word 0 ; NMI-Buffer
|
||||
idtext !text "MacEdV0" ; RAM-Kennung
|
||||
scratch !byte "s" ; DOS-String
|
||||
dospre !text "0:"
|
||||
dosname !text "-Anleitung .txt,p," ; Default
|
||||
dosmode !text "r"
|
||||
filepara !byte 22, lf, lf, 8
|
||||
!word dospre
|
||||
killpara !byte 19, 15, 15, 8
|
||||
!word scratch
|
||||
idfile !text "FormatVersion1.0"
|
||||
; Farben:
|
||||
; 2rufRGBI-Format
|
||||
clrcrsr !byte %##.##..# ; Cursor
|
||||
clrback !byte %........ ; Screen (xxxxRGBI-Format)
|
||||
clraktv !byte %#...###. ; Aktive Flags
|
||||
clrinak !byte %#......# ; Inaktive
|
||||
clrmenu !byte %##..##.# ; Menu
|
||||
clrmenu1 !byte %#...#### ; aktives Menu
|
||||
clraktl !byte %##..#### ; Menupunkt
|
||||
clrboxs !byte %#....### ; Menuboxen
|
||||
!byte %#....#.# ; Dialogboxen
|
||||
!byte %#..##..# ; Warnungen
|
||||
; Vars
|
||||
bank !byte 0 ; Bankbuffer
|
||||
memin !word 0 ; Startaddy Vektoren
|
||||
txts !word 0 ; Startaddy Text
|
||||
unnamed !byte TRUE ; ist Text benannt ?
|
||||
changes !byte FALSE ; Sind Changes saved ?
|
||||
nwfrm !byte FALSE ; neues Bild ?
|
||||
blockflag !byte FALSE ; Block definiert ?
|
||||
wrapflag !byte TRUE ; PARWing ?
|
||||
esca !byte TRUE ; AutoInsert ?
|
||||
updatewbi !byte FALSE ; Flag-Redraw n<>tig ?
|
||||
repeatedtry !byte FALSE ; Schon fr<66>her gestartet ?
|
||||
loadflag !byte 0 ; 0 = LOAD (/MERGE)
|
||||
txtname !text "unbenannt .txt"
|
||||
mrgname !text "merge .txt"
|
||||
newname !text "unbenannt .txt"
|
||||
lodname !text "unbenannt .txt"
|
||||
xindex !byte 0 ; Index-Puffer
|
||||
; Folgende Vars werden per x indiziert
|
||||
SCR = 0 ; x-Wert
|
||||
scrx !byte 0 ; Display
|
||||
scry !word 0
|
||||
ANF = 3 ; x-Wert
|
||||
anfx !byte 0 ; Blockstart
|
||||
anfy !word 0
|
||||
END = 6 ; x-Wert
|
||||
endx !byte 0 ; Ende
|
||||
endy !word 0
|
||||
POS = 9 ; x-Wert
|
||||
posx !byte 0 ; Cursor
|
||||
posy !word 0
|
||||
TMP = 12 ; x-Wert
|
||||
tmpx !byte 0 ; temp
|
||||
tmpy !word 0
|
||||
ZZA = 15 ; x-Wert
|
||||
llen !byte preflen ; Zeilenlaenge
|
||||
zzan !word 0 ; vorhandene Zeilen
|
||||
ZZB = 18 ; x-Wert
|
||||
byte !byte 0 ; akt. Zeichen
|
||||
zzbe !word 0 ; benutzte Zeilen
|
||||
WRP = 21 ; x-Wert
|
||||
wrpx !byte 0 ; Wrap
|
||||
wrpy !word 0
|
||||
PRW = 24 ; x-Wert
|
||||
prwx !byte 0 ; Parw
|
||||
prwy !word 0
|
||||
|
||||
; Tabs:
|
||||
etab ; ESC-Jumps
|
||||
!word ESC_at, ESC_a, ESC_b, ESC_c
|
||||
!word ESC_d, 0, 0, ESC_g
|
||||
!word ESC_h, ESC_i, ESC_j, ESC_k
|
||||
!word 0, 0, 0, ESC_o
|
||||
!word ESC_p, ESC_q, 0, 0
|
||||
!word ESC_t, 0, 0, 0
|
||||
!word 0, 0, 0, 0
|
||||
!word 0, 0, 0, 0
|
||||
ctab ; Command-Jumps 1. Achtel
|
||||
!word 0, 0, F_un, F_menu
|
||||
!word 0, F_c, 0, F_bell
|
||||
!word 0, F_tab, F_lfeed, 0
|
||||
!word F_ffeed, F_cr, F_text, F_fn
|
||||
!word 0, F_gcd, F_rn, F_home
|
||||
!word F_dcl, F_sf, F_sk, F_su
|
||||
!word F_st, F_sw, F_sl, F_esc
|
||||
!word F_c, F_gcr, F_c, F_c
|
||||
; 5. Achtel
|
||||
!word F_dir, F_c, F_uf, F_fbox
|
||||
!word F_hlp, F_f, F_f, F_f
|
||||
!word F_f, F_f, F_f, F_f
|
||||
!word F_f, F_cs, F_graphic, F_ff
|
||||
!word F_c, F_gcu, F_rf, F_gsot
|
||||
!word F_insert, F_c, F_c, F_c
|
||||
!word F_c, F_c, F_c, F_c
|
||||
!word F_c, F_gcl, F_c, F_c
|
||||
; 8. Achtel
|
||||
!word F_bttnf, F_gosys, 0, 0
|
||||
!word F_info, F_f, F_f, F_f
|
||||
!word F_f, F_f, F_f, F_f
|
||||
!word F_f, 0, F_geol, F_print
|
||||
!word F_glu, F_gau, F_scrnu, F_geot
|
||||
!word F_dword, F_save, F_saveas, F_rnmtxt
|
||||
!word F_gtl, F_fmtl, F_fmtr, F_fmtm
|
||||
!word F_fmtb, F_gwl, F_gpu, 0
|
||||
; 4. Achtel
|
||||
!word F_bttnn, F_goout, 0, 0
|
||||
!word F_mode, 0, 0, 0
|
||||
!word 0, 0, 0, 0
|
||||
!word 0, 0, F_gsol, F_new
|
||||
!word F_gld, F_gad, F_scrnd, F_ahome
|
||||
!word F_dcr, F_loadas, F_mergeas, F_find
|
||||
!word F_gtr, F_cut, F_copy, F_paste
|
||||
!word F_move, F_gwr, F_gpd, F_middle
|
||||
37
examples/trigono.a
Normal file
37
examples/trigono.a
Normal file
@@ -0,0 +1,37 @@
|
||||
;ACME 0.93
|
||||
!to "trigono.o", plain
|
||||
*=$c000
|
||||
|
||||
PI = 3.14159265358979323846
|
||||
|
||||
!raw "cos[0,pi/2] scaled to 0-255 range"
|
||||
!align $f, 0, 0 ; make output file look better in hex editor :)
|
||||
|
||||
!for x, 256 {
|
||||
!byte cos(float(x-1) / 255 * PI/2) * 255 + 0.5
|
||||
}
|
||||
; "x-1" converts interval [1,256] to interval [0,255]
|
||||
; "float()" makes sure this calculation is done in float mode now
|
||||
; "/255*half_PI" converts interval [0,255] to interval [0,PI/2]
|
||||
; "cos()" returns cosine. Wow.
|
||||
; "*255" converts interval [0,1] to interval [0,255]
|
||||
; "+0.5" ensures correct rounding to integer
|
||||
|
||||
!align $f, 0, 0
|
||||
!raw "sin[-pi/2,pi/2] scaled to full range of 16b.16b fixed point"
|
||||
!align $f, 0, 0
|
||||
|
||||
!for x, 1024 {
|
||||
!32 sin(float(x-513) / 1024 * PI) * 65536 + 0.5
|
||||
}
|
||||
|
||||
;undefined = 0.0 / 0.0 ; throws error when active
|
||||
;range = arcsin(-10) ; throws error when active
|
||||
!by 1 / 2 * 2 ; should give 0
|
||||
!by 1 / 2 * 2.0 ; should give 0
|
||||
!by 1 / 2.0 * 2 ; should give 1
|
||||
!by 1 / 2.0 * 2.0 ; should give 1
|
||||
!by 1.0 / 2 * 2 ; should give 1
|
||||
!by 1.0 / 2 * 2.0 ; should give 1
|
||||
!by 1.0 / 2.0 * 2 ; should give 1
|
||||
!by 1.0 / 2.0 * 2.0 ; should give 1
|
||||
BIN
examples/trigono.exp
Normal file
BIN
examples/trigono.exp
Normal file
Binary file not shown.
Reference in New Issue
Block a user