; Light pen machine code extracted from "Light Pen Sampler"
; basic tape maybe written by Craig J Anderson for H.A.R.D.
; see: BallyAlley group Message #7285 "A trip to my attic..."
; Tue Mar 17, 2009 11:56 pm from Ronaldo Goulart below END
;
; CPU Type: Z80 for the Bally Professional Arcade machine
;
; Created with dZ80 2.0 using script "BallyHVG.LUA" by RCD
;
; Re-assembles correctly with: zmac -i -m LIGHTPEN.ASM
;
; Reverse-engineered by Richard C Degler, From Scratch(tm)
; begining blah on Wednesday, 03 of March 2010 at 05:16 PM
;

; "Sure, I'd be glad to release the software into the public domain.
; That includes any software on any of the A.R.D. tapes, the H.A.R.D.
; tapes, and all the programs published in CURSOR, Arcadian and the
; Bally Express (DMA graphics, 3x5 character set, etc.) Have fun!"
;
; C. J. Anderson
;
; Not archived yet - but here's a picture of the cassette shell :
; http://ballyalley.com/pics/cassette_pics/hard/light_pen_sampler.jpg
;

        NOLIST

        INCLUDE "HVGLIB.H"      ; HOME VIDEO GAME LIBRARY

; define as NORMEM + $4F*BYTEPL + $18 (onscreen in line 79 ??)
TMPSTK  EQU     $4C70           ; TeMPorary STacK area

        LIST

        ORG     $4C80
L4C80:
        DI      
        EXX     
        LD      A,$4C
        LD      I,A
        LD      A,$E0
        OUT     ($0D),A         ; Interrupt vector at L4CE0
        EXX     
        EI      
        RET     

; 83 NULL bytes for ??
; L4C8D:
        DEFS    $53   

; Interrupt Vector
L4CE0:
        DW      L4CE3
        DB      $00             ; spare NOP     

; Interrupt Routine
L4CE3:
        CALL    $20B0           ; do TBIINT in BALLY Basic
; note:   CALL    $21FD           ; [or TBIINT in ASTRO Basic instead]
        DI      
        LD      (TMPSTK),SP     ; store old Stack Pointer
        LD      SP,TMPSTK       ; new Stack Pointer
        PUSH    AF              ; store environment
        PUSH    BC
        PUSH    DE
        PUSH    HL
        PUSH    IX
        PUSH    IY
        IN      A,(POT0)        ; read &(28) for Knob #1 = 0 to 255
        LD      (L4D3A),A       ; store as Vector Block VBTIMB for steps

        SYSTEM  INTPC           ; UPI INTerPret with Context create
        ;
        DO      MCALL           ; UPI Macro CALL interpreter subroutine
        DW      L4D18           ; ... Macro Address (to X-OR on with Color 2)
        ;
        DO      VECT            ; UPI VECTor move coordinate pair
        DW      L4D38           ; ... Vector Block
        DW      L4D20           ; ... Limit Table
        ;
        DO      MCALL           ; UPI Macro CALL interpreter subroutine
        DW      L4D18           ; ... Macro Address (again to X-OR back off)
        ;
        DONT    XINTC           ; UPI eXit INTerpreter with Context
        ;
        POP     IY              ; restore environment
        POP     IX
        POP     HL
        POP     DE
        POP     BC
        POP     AF
        LD      SP,(TMPSTK)     ; restore Stack Pointer
        EI      
        RET     
        DB      $00             ; spare NOP     

; macro call to here
L4D18:
        DO      VWRITR          ; UPI Vector WRITe Relative
        DW      L4D38           ; ... Vector Block
        DW      L4D24           ; ... Pattern Address
        ;
        DONT    MRET            ; UPI Macro RETurn from interpreter subroutine
        ;
        DB      $00             ; spare NOP
        DB      $00             ; spare NOP

; Vector Limit table
L4D20:
        DB      $00             ; X_LL =  0 (Left)
        DB      $98             ; X_LU =152 (Right)

        DB      $00             ; Y_LL =  0 (Top)
        DB      $40             ; Y_LU = 64 (Bottom)

; next is an 8 x 8 block sampled from the screen in a grid 10 pixels apart
; by this reworked BASIC routine (C was a constant but added to every use)
; 2000 B=0;FOR A=35TO -35STEP -10;D=0;B=B+1
; 2010 D=(PX(-35,A)x128)+(PX(-25,A)x32)+(PX(-15,A)x8)+(PX(-5,A)x2)
; 2020 D=D+(PX(5,A)x(-32767))+PX(15,A)x8192+(PX(25,A)x2048)+(PX(35,A)x512)
; 2030 @(B)=D;NEXT A;GOTO 9
;
; simulation of a triangle on screen, interlaced - can ONLY toggle Color 2
L4D24:
        DB      $00             ; X offset = 0
        DB      $00             ; Y offset = 0
        DB      $02             ; Width in bytes
        DB      $08             ; Height
; snap note: comment shows using 2 bits per pixel
        DW      $0080           ;(0)0 0 0 2 0 0 0 <-- HotSpot
        DW      $0280           ; 0 0 0 2 2 0 0 0
        DW      $02A0           ; 0 0 0 2 2 2 0 0
        DW      $0AA0           ; 0 0 2 2 2 2 0 0
        DW      $0AA8           ; 0 0 2 2 2 2 2 0
        DW      $2AA8           ; 0 2 2 2 2 2 2 0
        DW      $2AAA           ; 0 2 2 2 2 2 2 2
        DW      $AAAA           ; 2 2 2 2 2 2 2 2

; Vector Block
L4D38:
        DB      $21             ; VBMR for X-OR in Color, Shift 1
        DB      $80             ; VBSTAT for VBSACT on, VBBLNK off
L4D3A:  DB      $00             ; VBTIMB off, updated above
        DW      $0005           ; VBDX for 0.01953125 pixels/step
        DW      $0000           ; VBX = 0 (Left side)
        DB      $03             ; VBXCHK for VBCLMT & VBCREV
        DW      $0005           ; VBDY for 0.01953125 pixels/step
        DW      $0000           ; VBY = 0 (Top edge)
        DB      $03             ; VBYCHK for VBCLMT & VBCREV
        DB      $00             ; VBOA not used, only one byte defined

        END


http://tech.groups.yahoo.com/group/ballyalley/message/7285
A trip to my attic...


Message #7285 of 8781 
Tue Mar 17, 2009 11:56 pm
Ronaldo Goulart <realpeterjack@...> 
realpeterjack 

Re: [ballyalley] Re: A trip to my attic... 


I had no problems here reading the program, but I had to convert it to
22050 Hz prior to processing it through KCS. You must remember KCS requires
wave files to be strictly 8 bit 22050 Hz (this one was already 8 bit, but
it was 44100 Hz).

This is actually the first time I'm using prg2txt under Vista. Previously I
used XP, so I was used to just open a CMD window and use both KCS and
prg2txt in it. But as vista dropped DOS support, KCS requires DOSBox now,
and as prg2txt is a native windows program, it requires a separate Vista
CMD. This is quite annoying...

Ronaldo

1 .
2 NT=0;CLEAR ;CY=20;PRINT "ASCII INPUT ";CY=-20;PRINT "GRAPHICS DEMO
3 :INPUT ;A=&(14)
4 IF &(14)=AGOTO 4
5 IF &(14)<100GOTO 3000
6 GOTO 1000
9 &(15)=102
10 CLEAR
20 A=19584;B=A;C=590
30 D=-9741;GOSUB C
40 D=19518;GOSUB C
50 D=18413;GOSUB C
60 D=-8130;GOSUB C
70 D=3539;GOSUB C
80 D=-1063;GOSUB C
90 D=201;GOSUB C
100 A=19680
110 D=19683;GOSUB C
120 A=19683
130 D=-20275;GOSUB C
140 D=-3296;GOSUB C
150 D=29677;GOSUB C
160 D=19568;GOSUB C
170 D=28721;GOSUB C
180 D=-2740;GOSUB C
190 D=-10811;GOSUB C
200 D=-8731;GOSUB C
210 D=-539;GOSUB C
220 D=-9243;GOSUB C
230 D=12828;GOSUB C
240 D=19770;GOSUB C
250 D=255;GOSUB C
260 D=6151;GOSUB C
270 D=16205;GOSUB C
280 D=19768;GOSUB C
290 D=19744;GOSUB C
300 D=6151;GOSUB C
310 D=589;GOSUB C
320 D=-7683;GOSUB C
330 D=-7715;GOSUB C
340 D=-11807;GOSUB C
350 D=-3647;GOSUB C
360 D=31725;GOSUB C
370 D=19568;GOSUB C
380 D=-13829;GOSUB C
390 A=19736
400 D=14367;GOSUB C
410 D=9293;GOSUB C
420 D=2125;GOSUB C
430 A=19744
440 D=-26624;GOSUB C
450 D=16384;GOSUB C
460 D=0;GOSUB C
470 D=2050;GOSUB C
480 FOR Q=1TO 8;D=@(Q);GOSUB C;NEXT Q
570 D=-32735;GOSUB C
572 D=1280;GOSUB C
574 D=0;GOSUB C
576 D=768;GOSUB C
577 D=5;GOSUB C
578 D=0;GOSUB C
579 D=3;GOSUB C
580 CALL(B);STOP
590 %(A)=D;A=A+2;RETURN
1000 CLEAR ;:INPUT
1010 FOR A=-40TO 40STEP 10;BOX A,0,1,80,1;BOX 0,A,80,1,1;NEXT A
1020 FOR A=-35TO 35STEP 10
1030 BOX A-10,-43,2,2,2;BOX A,-43,2,2,1
1040 B=&(14)
1050 IF &(14)=BGOTO 1050
1060 IF &(14)<35BOX A,35,9,9,1
1070 IF &(14)>35IF &(14)<55BOX A,25,9,9,1
1080 IF &(14)>55IF &(14)<75BOX A,15,9,9,1
1090 IF &(14)>75IF &(14)<95BOX A,5,9,9,1
1100 IF &(14)>95IF &(14)<115BOX A,-5,9,9,1
1110 IF &(14)>115IF &(14)<135BOX A,-15,9,9,1
1120 IF &(14)>135IF &(14)<155BOX A,-25,9,9,1
1130 IF &(14)>155IF &(14)<175BOX A,-35,9,9,1
1140 IF &(14)>175NEXT A;:RETURN ;GOTO 2000
1150 GOTO 1040
2000 B=0;FOR A=35TO -35STEP -10;C=-35;D=0;B=B+1
2010 D=(PX(C,A)×128)+(PX(C+10,A)×32)+(PX(C+20,A)×8)+(PX(C+30,A)×2)+(PX(C+40,A)×(-32767))+PX(C+50,A)×8192
2020 D=D+(PX(C+60,A)×2048)+(PX(C+70,A)×512)
2030 @(B)=D;NEXT A;GOTO 9
3000 CLEAR ;A=-80
3002 C=&(14);IF &(14)=CGOTO 3002
3005 IF &(14)>190A=A+6;CX=A;CY=40;TV=B
3010 CX=-80;CY=0;B=&(14)÷7+65;IF B>90B=32
3020 TV=B;GOTO 3002
:RETURN
>

--------------------------------------

Paul Thacker escreveu:
>
>
> Good to hear it's still in the works. I was mainly just giving an
> archiving status update. Actually, I'm wondering if you could look at
> something. Brett asked about light pen programs, and I confirmed that I
> do in fact have one from his tape collection, a 300 baud program labeled
> Light Pen Sampler. It loads fine on my Astrocade, and describes itself
> as ASCII INPUT GRAPHICS DEMO. I haven't tried much to use it, but I
> assume it needs a light pen, which I don't have. I was going to use KCS
> and prg2txt to post the source code, like I did with those other
> programs, but it's not working correctly. I saved the recording as
> 8-bits, then ran KCS and got a PRG file back. But when I run that
> through either prg2txt, or back through KCS to regenerate a WAV file, I
> just get garbage. Could you see if you have any better luck, or can
> figure out what's wrong? The recording should be among the 300 baud
> recordings Adam sent you, in the "working" folder, named "Light Pen
> Sampler (author unknown).wav"
>
> Paul
