nedoPC.org

Electronics hobbyists community established in 2002
Atom Feed | View unanswered posts | View active topics It is currently 28 Mar 2024 17:04



Reply to topic  [ 9 posts ] 
Programs for Tunguska 
Author Message
Retired

Joined: 03 Aug 2003 22:37
Posts: 1474
Location: Moscow
Reply with quote
I decided to create special topic for Tunguska programs source codes since every post can be very big.


10 Mar 2008 01:38
Profile
Retired

Joined: 03 Aug 2003 22:37
Posts: 1474
Location: Moscow
Reply with quote
Here is another version of my colour test table. This one shows 729 colours as blocks of 8 x 8 pixels of same colour in 27 x 27 blocks matrix 8-)

Here is how does it look on the screen:

Image

Here is source code:

Code:
; Color table 3 for Tunguska, works in raster mode (729 colors)
;
;  Assemble into demo.ternobj
;  Run 'tunguska image.ternobj -F demo.ternobj'
;  Type 'LOADSUB'
;

@ORG    %DDD000
        ; Bootstrap function
        ;
        ; Read page 2 from disk into page 2 in memory
        LDA     #2
        LDY     #2
        JSR     (jumpvector.fl_read_block)
        JMP     colortable3

; These won't be copied. They are also present in the host at the same
; memory location.

@ORG    %001000
jumpvector:
.getstring:   @DW     0
.feedscreen:  @DW     0
.putchar:     @DW     0
.putnon:      @DW     0
.puts:        @DW     0
.strcmp:      @DW     0
.strlen:      @DW     0
.index:       @DW     0
.strspn:      @DW     0
.strcspn:     @DW     0
.memset6:     @DW     0
.random:      @DW     0
.between:     @DW     0
.repaint:     @DW     0
.fl_read_block: @DW     0
.fl_write_block: @DW    0
.fl_dump_memory: @DW      0
.raster:      @DW         0
.putpixel:    @DW         0
.getpixel:    @DW         0

@ORG    %002000

raster:
@EQU    .width      324
@EQU    .height     243
@EQU    .mempos     %DDBDDD

colortable3:
; Enable raster mode
        LDA   #%00C
        STA   %DDDDDB
        LDA   #27
        STA   .ctx
        LDA   #27
        STA   .cty
.nxtbl: JSR   .drawblock_ex
        LDA   .x
        CLC
        ADD   #9
        STA   .x
        INC   .c
        DEC   .ctx
        LDA   .ctx
        CMP   #0
        JNE   .nxtbl
        LDA   #40
        STA   .x
        LDA   #27
        STA   .ctx
        LDA   .y
        CLC
        ADD   #9
        STA   .y
        DEC   .cty
        LDA   .cty
        CMP   #0
        JNE   .nxtbl
.idleloop:
        JMP   .idleloop

.ctx:   @DT   0
.cty:   @DT   0

.drawblock_ex:
        LDA   #8
        STA   .dblc
        LDA   .y
        STA   .orgy
        LDA   .x
        STA   .orgx
.nxtln: LDA   #8
        JSR   .drawline_ex
        INC   .orgy
        DEC   .dblc
        LDA   .dblc
        CMP   #0
        JNE   .nxtln
        RST

.dblc:  @DT   0
.dbx:   @DT   0
.dby:   @DT   0
.orgx:  @DT   0
.orgy:  @DT   0

.drawline_ex:
        STA   .dlvc
        LDA   .orgy
        STA   .dly
        LDA   .orgx
        STA   .dlx
.nxtpx: JSR   .putpixel_ex
        INC   .dlx
        DEC   .dlvc
        LDA   .dlvc
        CMP   #0
        JNE   .nxtpx
        RST

.dlvc:  @DT   0
.dly:   @DT   0
.dlx:   @DT   0

.putpixel_ex:
        LAD   raster.mempos
        STX   .mem
        STY   .mem+1
        CLC
        LDA   .dlx
        ADD   .mem+1
        STA   .mem+1
        LDA   #0
        ADD   .mem
        STA   .mem
        CLC
        LDA   #raster.width
        MLL   .dly
        ADD   .mem+1
        STA   .mem+1
        LDA   #0
        ADD   .mem
        STA   .mem
        CLC
        LDA   #raster.width
        MLH   .dly
        ADD   .mem
        STA   .mem
        LDA   .c
        STA   (.mem)
        RST

.x:     @DT   40
.y:     @DT   0
.c:     @DT   %DDD
.mem:   @DW   0



Please note: this is not optimised version, I'll update the code soon to make it slightly faster and better colours order.


10 Mar 2008 01:52
Profile
Maniac

Joined: 17 Sep 2012 13:36
Posts: 277
Location: 81.170.128.52
Reply with quote
That's kinda neat. I'm thinking I might add an assembler macro that adds a shift between memory location and disk location, so that you can save code intended for a specific memory location (with correct jump addresses and all that) on a different disk location. This would make it possible to store many different programs on the same disk.


10 Mar 2008 03:52
Profile
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22412
Location: Silicon Valley
Reply with quote
eudoxie wrote:
That's kinda neat. I'm thinking I might add an assembler macro that adds a shift between memory location and disk location, so that you can save code intended for a specific memory location (with correct jump addresses and all that) on a different disk location. This would make it possible to store many different programs on the same disk.


I think that boot program and other programs have to be separate binaries - see my approach with RBOOT.A and RTGTEST.A (see tunguska-alpha-2_2-win). Also I plan to create some kind of "program manager" as boot for disk(s)...


10 Mar 2008 16:14
Profile WWW
Maniac

Joined: 17 Sep 2012 13:36
Posts: 277
Location: 81.170.128.52
Reply with quote
A snow simulator.

Code:
; Snow simulator (suffers from the dreaded "bars of doom" syndrome)
;
; Loaded with LOADSUB
;
;

; ---------------------------------------------------------
;
;
;
;  Code begins
;

; Memory position for vectors
;
;
vector      @EQU   %DDB000
vector.COLOR   @EQU   vector         ; Offsets for color, x and y position
vector.XPOS   @EQU   vector+1
vector.YPOS   @EQU   vector+2
vector.LENGTH   @EQU   vector+3 - vector   ; Length of a vector in memory

@ORG   %DDD000
   ; Bootstrap function
   ;
   ; Read page 2 from disk into page 2 in memory
   LDA   #2
   LDY   #2
   JSR   (jumpvector.fl_read_block)
        ; ... and page 3
   LDA   #3
   LDY   #3
   JSR   (jumpvector.fl_read_block)

   JMP   snow

; These won't be copied. They are also present in the host at the same
; memory location.

@ORG   %001000
jumpvector:
.getstring:   @DW   0
.feedvector:   @DW   0
.putchar:   @DW   0
.putnon:   @DW   0
.puts:      @DW   0
.strcmp:   @DW   0
.strlen:   @DW   0
.index:      @DW   0
.strspn:   @DW   0
.strcspn:   @DW   0
.memset6:   @DW   0
.random:   @DW   0
.between:   @DW   0
.repaint:   @DW   0
.fl_read_block: @DW   0
.fl_write_block: @DW   0
.mouse.x       : @DW   0
.mouse.y       : @DW   0


@ORG   %002000

snow:
      LDA   #150      ; Lower this value if too slow, increase if too fast
      STA   %444441
      JSR   init
      LDX   #%DDD

; Increment Y position and add random values to x position
;

.loop:
      LDA   vector.YPOS,X
      INC    A
      STA   vector.YPOS,X
      JSR   (jumpvector.random)
      EOR   %#001
      ADD   vector.XPOS,X
      STA   vector.XPOS,X

      LDA   vector.YPOS+vector.LENGTH,X
      INC   A
      STA   vector.YPOS+vector.LENGTH,X
      LDA   vector.XPOS,X
      INC   A
      STA   vector.XPOS+vector.LENGTH,X

      LDA   vector.YPOS+2*vector.LENGTH,X
      INC   A
      STA   vector.YPOS+2*vector.LENGTH,X
      LDA   vector.XPOS,X
      STA   vector.XPOS+2*vector.LENGTH,X

      TXA
      CLC
      ADD   #9
      TAX

      JMP   .loop
   


; Initiate vectors
;
;
;

init:
      LDA   #%003
      STA   %DDDDDB
      LDX   #%DDD
.loop:
      ; Vector #1
      LDA   #%DDD
      STA   vector.COLOR,X
      JSR   (jumpvector.random)
      STA   vector.XPOS,X
      JSR   (jumpvector.random)
      STA   vector.YPOS,X

      ; Vector #2
      LDA   #%444
      STA   vector.COLOR+vector.LENGTH,X
      LDA   vector.XPOS,X
      INC   A
      STA   vector.XPOS+vector.LENGTH,X
      LDA   vector.YPOS,X
      STA   vector.YPOS+vector.LENGTH,X
   
      ; Vector #3
      LDA   #%444
      STA   vector.COLOR+2*vector.LENGTH,X
      LDA   vector.XPOS,X
      STA   vector.XPOS+2*vector.LENGTH,X
      LDA   vector.YPOS,X
      INC   A
      STA   vector.YPOS+2*vector.LENGTH,X
   
      TXA
      CLC
      ADD   #9
      TAX
      CMP   #%DDD
      JNE   .loop


      RST

progend    @EQU   $$


22 Mar 2008 12:48
Profile
Maniac

Joined: 17 Sep 2012 13:36
Posts: 277
Location: 81.170.128.52
Reply with quote
Image

"Ant colony" simulator. Or multiple random walks with tracking.

Code:
; Ant colony
;
; Loaded with LOADSUB
;
;

; ---------------------------------------------------------
;
;
;
;  Code begins
;

@ORG   %DDD000
   ; Bootstrap function
   ;
   ; Read page 2 from disk into page 2 in memory
   LDA   #2
   LDY   #2
   JSR   (jumpvector.fl_read_block)
        ; ... and page 3
   LDA   #3
   LDY   #3
   JSR   (jumpvector.fl_read_block)

   JMP   ant

; These won't be copied. They are also present in the host at the same
; memory location.

@ORG   %001000
jumpvector:
.getstring:   @DW   0
.feedvector:   @DW   0
.putchar:   @DW   0
.putnon:   @DW   0
.puts:      @DW   0
.strcmp:   @DW   0
.strlen:   @DW   0
.index:      @DW   0
.strspn:   @DW   0
.strcspn:   @DW   0
.memset6:   @DW   0
.random:   @DW   0
.between:   @DW   0
.repaint:   @DW   0
.fl_read_block: @DW   0
.fl_write_block: @DW   0
.mouse.x:    @DW   0
.mouse.y:   @DW   0
.putpixel:   @DW   0
.getpixel:   @DW   0
.putpixel3:   @DW   0      


@ORG   %002000

@EQU   ANTS   10   ; Total number of ants
ant:
      ; Use AGDP to clear screen
      ;
      ;
      ;
      LAD   %DDBDDD
      STX   %DDDDD1
      STY   %DDDDD2
      LDA   #0
      STA   %DDDDD3
      LDA   #%DDD
      STA   %DDDDD4
      LAD   108*729
      STX   %DDDDCD
      STY   %DDDDCC
      LDA   #11
      STA   %DDDDD0

      ; Enable raster729-mode
      LDA   %DDDDDB
      AND   #%44B
      STA   %DDDDDB

      LDX   #0

      ; Give the ants random initial positions
      ;
.init:      
      JSR   (jumpvector.random)
      PHX
      LDX   #%000
      LDY   #%400
      JSR   (jumpvector.between)
      PLX
      STA   .X,X
      JSR   (jumpvector.random)
      PHX
      LDX   #%000
      LDY   #%300
      JSR   (jumpvector.between)
      PLX
      STA   .Y,X
      
      INX
      TXA
      CMP   #ANTS
      JNE   .init   

      LDX   #0

      ; Main loop
.loop:

      ; Increase X position of the X:th ant
      JSR   (jumpvector.random)   ; Get random value
      EOR   #%001         ; Mask all but last trit
      CLC
      ADD   .X,X         ; Add to X pos
      PHX
      LDX   #%000
      LDY   #%400
      JSR   (jumpvector.between)   ; Impose screen clamps
      PLX
      STA   .X,X         ; Store in .X[X]

      JSR   (jumpvector.random)   ; Get a random value
      EOR   #%001         ; mask out all but last trit
      CLC
      ADD   .Y,X         ; Add to Y pos
      PHX
      LDX   #%000
      LDY   #%300
      JSR   (jumpvector.between)   ; Impose clamps
      PLX
      STA   .Y,X         ; Store in .Y[X]

      PHX            ; Draw pixel on screen
      TXA            ;
      LDY   .Y,X         ;
      LDX   .X,X         ;
      JSR   (jumpvector.putpixel)   ; <-- here
      PLX

      INX            ; Increase X until all
      TXA            ; ants have been drawn,
      CMP   #ANTS         ; then reset
      JNE   .notrimx
      LDX   #0
.notrimx:   
      JMP   .loop

.X:      @REST   ANTS
.Y:      @REST   ANTS      




22 Mar 2008 14:16
Profile
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22412
Location: Silicon Valley
Reply with quote
I tried to build "snow" using latest CVS version:

Code:
* assembler.cc[223]: Unresolved variable DD
* assembler.cc[331]: Error during assembly of snow.asm, line 68


I changed #%DD to #%DDD - it's working but from time to time I see vertical and horizontal white lines across the screen along with snow


30 Mar 2008 19:52
Profile WWW
Maniac

Joined: 17 Sep 2012 13:36
Posts: 277
Location: 81.170.128.52
Reply with quote
Hm, I'll upate my post with the snow.asm-listing.

The bars are just lazy programming, I could test for integral overflow, but that would vastly increase the complexity (and decrease the speed) of the program...


31 Mar 2008 03:51
Profile
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22412
Location: Silicon Valley
Reply with quote
Post 
Some images are lost in time...

_________________
:dj: https://mastodon.social/@Shaos


10 Nov 2012 06:59
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 9 posts ] 

Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software.