From 9733bfd0e0546f76e9a64dd3ae513896bbf19718 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Wed, 26 Oct 2022 03:29:16 -0400 Subject: Menu options: add New, remove Exit and WriteCSV. --- dla.s | 227 +++++++++++++++++++++++++++++++++--------------------------------- 1 file changed, 113 insertions(+), 114 deletions(-) (limited to 'dla.s') diff --git a/dla.s b/dla.s index 2d96928..5b069b7 100644 --- a/dla.s +++ b/dla.s @@ -21,7 +21,6 @@ DMA_ON = $21 DEFAULTPART = 1000 - screenptr = SAVMSC maxparticles = $80 ; 2 bytes addtmp = $82 pixptr = $82 @@ -46,19 +45,36 @@ fptmp = $05a0 cloksav = $a0 seedtype = $9f + old_dma = $9c + old_dl = $9d - ; start of init segment. gets overwritten by the main program... - ; and since the rest of the xex isn't loaded yet, can't call - ; subroutines from it! xex_org loadaddr .include "io.s" ; printchrx and getchrx -msg: - .byte "Diffusion Limited Aggregate",$9b - .byte "Urchlay's ASM version 0.0.7",$9b,$9b - .byte "How many particles [",.sprintf("%d", DEFAULTPART),"]? ",$0 -msg2: - .byte $9b,"Seed Type: ",$9b,"1=Dot 2=Plus 3=4Dots 4=Line [1]? ",$0 + + ; init stuff gets done once, at startup init: + lda SDMCTL + sta old_dma + lda SDLSTL + sta old_dl + lda SDLSTH + sta old_dl+1 + + ; "New" option jumps here, restore GR.0 screen +getargs: + lda #$90 + sta COLOR2 + lda #$0e + sta COLOR1 + lda #$ff + sta CH + lda old_dl + sta SDLSTL + lda old_dl+1 + sta SDLSTH + lda old_dma + sta SDMCTL + ; set default particles (if user just hits return) lda # ldx #$10 lda #3 ; OPEN sta ICCOM,x @@ -391,6 +366,7 @@ saveimage: sta ICAX1,x jsr CIOV + ; write data to file ldx #$10 lda #$0b ; write binary record sta ICCOM,x @@ -404,16 +380,13 @@ saveimage: sta ICBLH,x jsr CIOV + ; CLOSE #1 ldx #$10 lda #$0c ; close sta ICCOM,x jsr CIOV jmp keyloop -diskerr: - sty textbuf -hang: jmp hang - ;;; Subroutine: set_limits ;;; Sets the X/Y min/max limits based on circlesize set_limits: @@ -432,7 +405,10 @@ set_limits: ;;; clear screen memory and point ANTIC to our display list. ;;; no arguments. trashes all registers. initscreen: - jsr set_screenptr + lda #screen + sta pixptr+1 ; first, clear linebuf and textbuf lda #0 @@ -447,10 +423,10 @@ isloop0: ldx #>screenbytes ; clear this many pages tay ; 0 again isloop: - sta (screenptr),y + sta (pixptr),y iny bne isloop - inc screenptr+1 + inc pixptr+1 dex bne isloop @@ -461,16 +437,7 @@ isloop: sta SDLSTL lda #>dlist sta SDLSTH -; fall through to next subroutine -;;; Subroutine: set_screenptr -;;; Set screenptr to the start of screen memory. -;;; Trashes A, preserves X and Y. -set_screenptr: - lda #screen - sta screenptr+1 rts ;;; Subroutine: plotsetup @@ -478,7 +445,7 @@ set_screenptr: ;;; - set pixmask to the mask for cursor_x. ;;; - set Y reg to the byte offset for cursor_x. ;;; - returns with cursor_x in X reg, pixmask in A reg too. -;;; Called by plot, unplot, and locate. +;;; Called by plot, unplot, and drunkwalk (a lot!) plotsetup: ldx cursor_y lda lineaddrs_l,x @@ -643,16 +610,18 @@ drawseed: pha rts +;;; Subroutine: seed_point +;;; draw initial point in center seed_point: - ; initial point in center lda #$7f sta cursor_x lda #$5f sta cursor_y jmp plot +;;; Subroutine: seed_long +;;; horizontal line, the width of the screen seed_long: - ; horizontal line, the width of the screen lda #$1 sta cursor_x lda #$5f @@ -665,8 +634,9 @@ slnoop: bne slnoop rts +;;; Subroutine: seed_plus +;;; plus share, made of two 20px lines intersecting in the center seed_plus: - ; plus, made of two 20px lines intersecting in the center lda #$7f sta cursor_x lda #$55 @@ -689,8 +659,9 @@ slloop: bne slloop rts +;;; Subroutine: seed_4pt +;;; four points, the corners of a 20px square seed_4pt: - ; four points, the corners of a 20px square lda #$75 sta cursor_x lda #$55 @@ -706,23 +677,52 @@ seed_4pt: sta cursor_y jmp plot -;;;;; end of executable code +;;; Subroutine: readline +;;; Read a line from E:, store result in linebuf. +;;; The terminating EOL ($9b) gets stored at the end. +;;; linebuf happens to be right where the FP ROM needs it for AFP. +readline: + lda #linebuf + sta INBUFF+1 + sta ICBAH + lda #0 + sta ICBLH + lda #10 + sta ICBLL + lda #5 + sta ICCOM + ldx #0 + jmp CIOV + +;;;;; end of executable code, data tables from here on out. + +; prompts +msg: + .byte $7d, "Diffusion Limited Aggregate",$9b + .byte "Urchlay's ASM version 0.0.7",$9b,$9b + .byte "Particle count range: 1 to 65535",$9b + .byte "How many particles [",.sprintf("%d", DEFAULTPART),"]? ",$0 +msg2: + .byte $9b,"Seed Type: ",$9b,"1=Dot 2=Plus 3=4Dots 4=Line [1]? ",$0 ; screen codes for menu menumsg: - .byte $00,$00,$00 ; 3 digits of minutes - .byte $00 ; 1 decimal point - .byte $00,$00 ; 2 digits fractional minutes - .byte $00 ; 1 the letter "m" - .byte $00,$00 ; 2 spaces - .byte 'S'-$20+$80 ; 1 - scrcode "ave " ; 3 - .byte 'R'-$20+$80 ; 1 - scrcode "edo " ; 4 - .byte 'E'-$20+$80 ; 1 - scrcode "xit?" ; 4 - .byte $80 ; 1 (cursor) - .byte $00,$00,$00 ; 3 (filler) + .byte $00,$00,$00 ; 3 digits of minutes + .byte $00 ; 1 decimal point + .byte $00,$00 ; 2 digits fractional minutes + .byte $00 ; 1 the letter "m" + .byte $00,$00 ; 2 spaces + .byte 'S'-$20+$80 ; 1 + scrcode "ave " ; 3 + .byte 'R'-$20+$80 ; 1 + scrcode "edo " ; 4 + .byte 'N'-$20+$80 ; 1 + scrcode "ew?" ; 4 + .byte $80 ; 1 (cursor) + .byte $00,$00,$00,$00 ; 4 (filler) menulen = * - menumsg - 1 ; filename for Save command @@ -792,6 +792,5 @@ xmasks: .word textbuf .byte jvb .word dlist - ;.out .sprintf("%d",* - dlist) xex_run init -- cgit v1.2.3