Jump to content

atari2601

New Members
  • Content Count

    11
  • Joined

  • Last visited

Posts posted by atari2601


  1. 5 minutes ago, e5frog said:

    No need to involve sleiszatrio, the code is standalone, no need for any other code.
    You use dasm.exe to compile it from command prompt:
    dasm codefilename.asm -f3 -oFILENAME.bin

    Your sample data sounds like some sort of thump or maybe like a puff when a steam engine is about to start. 

    Try this: 
     

    ; The format is 0
    ; High value is 140
    ; Low value is 110
    
        .byte $FF,$03,$02,$1D,$B5,$02,$02,$02,$02,$02,$2A,$18,$02,$03,$11,$2A
        .byte $6F,$65,$59,$76,$4E,$3F,$37,$43,$36,$01,$32,$42,$31,$3F,$52,$43
        .byte $2A,$44,$0C,$0B,$0F,$17,$45,$3B,$2D,$3D,$3D,$0D,$2F,$02,$0E,$2D
        .byte $39,$3E,$28,$0E,$0B,$08,$30,$3C,$2E,$39,$38,$13,$09,$0A,$2D,$39
        .byte $2D,$3C,$39,$1B,$04,$01,$03,$03,$34,$39,$29,$3D,$2B,$33,$3A,$37
        .byte $2B,$3D,$2D,$32,$42,$02,$03,$2D,$25,$44,$2B,$25,$56,$0C,$09,$92
        .byte $0B,$0B,$A9,$44,$0C,$44,$5B,$07,$4D,$5B,$0C,$2F,$58,$0D,$5E,$47
        .byte $08,$0B,$0C,$2B,$49,$08,$0D,$0C,$0C,$02,$1B,$0E,$16,$01,$03,$02
        .byte $0F,$0F,$02,$35,$0A,$0C,$09,$2A,$48,$10,$0B,$0A,$25,$10,$1A,$02
        .byte $10,$44,$15,$2F,$39,$25,$2B,$23,$2C,$84,$32,$14,$42,$16,$02,$02
        .byte $3A,$89,$6D,$2A,$56,$02,$0D,$4C,$32,$21,$38,$2B,$6B,$52,$4A,$30
        .byte $39,$24,$33,$8C,$3B,$3B,$FF,$69,$C0,$8D,$AA,$A1,$DE,$93,$FF,$5B
        .byte $CB,$80,$2C,$2E,$8D,$3D,$2C,$1F,$02,$0A,$02,$03,$02,$02,$30,$02
        .byte $06,$18,$02,$0F,$02,$05,$02,$03,$02,$02,$03,$02,$2C,$02,$03,$01
        .byte $0B,$02,$02,$02,$03,$02,$02,$02,$02,$02,$02,$02,$03,$04,$02,$02
        .byte $05,$02,$02,$03,$02,$02,$02,$0B,$02,$0E,$02,$03,$01,$0C,$02,$06
        .byte $03,$03,$01,$03,$02,$06,$02,$02,$02,$06,$02,$03,$1A,$02,$03,$02
        .byte $02,$15,$03,$02,$02,$02,$4B,$2B,$02,$06,$02,$0B,$02,$24,$3D,$01
        .byte $03,$02,$02,$0B,$01,$2B,$0B,$01,$03,$02,$49,$45,$39,$36,$37,$02
        .byte $02,$02,$03,$01,$03,$02,$02,$02,$3B,$02,$02,$4B,$2A,$2E,$3E,$31
        .byte $39,$30,$37,$41,$3C,$33,$33,$28,$32,$3A,$8B,$78,$AB,$39,$36,$30
        .byte $3C,$2D,$2F,$3F,$3B,$2B,$9D,$53,$2F,$2D,$3B,$26,$45,$19,$02,$02
        .byte $3D,$48,$3B,$2D,$39,$2F,$32,$22,$02,$01,$09,$09,$2F,$41,$35,$30
        .byte $3B,$02,$02,$2E,$2D,$01,$03,$02,$02,$03,$01,$29,$02,$02,$02,$02
        .byte $03,$01,$2B,$01,$03,$01,$03,$02,$02,$3A,$3B,$2D,$3B,$03,$01,$3A
        .byte $33,$34,$02,$02,$02,$02,$4C,$46,$20,$4C,$30,$22,$43,$32,$3F,$4A
        .byte $28,$32,$3E,$28,$43,$3A,$64,$66,$2F,$1E,$87,$32,$03,$02,$85,$41
        .byte $36,$30,$A4,$26,$3D,$2F,$2D,$94,$BE,$A4,$47,$1D,$02,$2E,$2A,$03
        .byte $12,$02,$25,$02,$15,$02,$03,$02,$0B,$01,$04,$02,$09,$02,$0F,$02
        .byte $0A,$02,$03,$02,$03,$02,$0B,$02,$03,$02,$02,$02,$03,$01,$03,$02
        .byte $03,$02,$02,$02,$06,$03,$06,$15,$03,$04,$02,$03,$02,$04,$02,$03
        .byte $02,$03,$02,$0A,$02,$04,$02,$03,$02,$04,$02,$0B,$02,$08,$02,$03
        .byte $02,$03,$02,$03,$02,$07,$02,$02,$02,$03,$02,$08,$02,$07,$02,$02
        .byte $03,$03,$02,$04,$02,$04,$02,$02,$03,$02,$03,$03,$02,$03,$04,$06
        .byte $04,$04,$03,$02,$03,$02,$03,$02,$03,$02,$02,$03,$07,$02,$02,$02
        .byte $03,$03,$08,$02,$07,$02,$03,$02,$03,$02,$05,$02,$09,$03,$03,$02
        .byte $03,$03,$02,$03,$03,$03,$03,$02,$03,$03,$03,$03,$09,$02,$08,$03
        .byte $03,$02,$02,$02,$06,$03,$09,$03,$03,$03,$06,$02,$02,$02,$03,$02
        .byte $02,$03,$03,$02,$02,$02,$02,$01,$03,$02,$03,$02,$03,$03,$02,$06
        .byte $02,$02,$03,$03,$02,$03,$03,$02,$03,$03,$0A,$02,$03,$03,$05,$02
        .byte $03,$03,$02,$03,$03,$02,$03,$03,$04,$03,$02,$03,$03,$02,$03,$03
        .byte $03,$03,$03,$02,$03,$04,$03,$03,$02,$02,$02,$02,$03,$02,$03,$05
        .byte $02,$03,$02,$03,$03,$03,$04,$02,$03,$02,$02,$03,$03,$03,$04,$02
        .byte $02,$03,$03,$04,$02,$03,$02,$03,$03,$09,$03,$02,$03,$02,$02,$07
        .byte $03,$05,$02,$06,$03,$02,$03,$02,$01,$02,$03,$02,$03,$02,$03,$02
        .byte $03,$03,$05,$06,$02,$02,$02,$03,$02,$02,$02,$03,$04,$06,$03,$03
        .byte $02,$02,$03,$02,$03,$02,$02,$06,$03,$03,$0F,$03,$03,$01,$04,$02
        .byte $16,$02,$03,$02,$04,$02,$03,$02,$03,$02,$02,$03,$03,$03,$02,$03
        .byte $01,$02,$04,$04,$03,$02,$03,$02,$03,$02,$02,$02,$03,$02,$02,$03
        .byte $04,$03,$03,$02,$02,$02,$03,$02,$03,$02,$02,$02,$02,$03,$04,$02
        .byte $02,$03,$03,$03,$02,$02,$03,$03,$02,$02,$02,$03,$02,$02,$03,$03
        .byte $06,$05,$03,$02,$03,$02,$0A,$03,$03,$02,$03,$02,$02,$02,$02,$03
        .byte $03,$03,$02,$03,$03,$02,$02,$02,$03,$02,$02,$02,$03,$02,$03,$02
        .byte $03,$06,$02,$03,$02,$02,$03,$02,$02,$05,$03,$03,$05,$05,$03,$02
        .byte $02,$03,$02,$03,$02,$02,$04,$03,$03,$05,$02,$03,$02,$03,$03,$02
        .byte $03,$02,$02,$03,$02,$03,$02,$02,$01,$02,$03,$03,$02,$02,$02,$03
        .byte $02,$02,$02,$03,$02,$02,$02,$04,$02,$03,$03,$03,$03,$03,$02,$04
        .byte $03,$03,$02,$02,$03,$03,$05,$03,$02,$02,$02,$02,$02,$02,$03,$02
        .byte $02,$03,$04,$06,$03,$03,$03,$05,$02,$02,$05,$03,$07,$02,$07,$02
        .byte $03,$02,$03,$02,$06,$01,$03,$02,$06,$02,$03,$02,$03,$03,$03,$02
        .byte $02,$02,$02,$02,$03,$02,$03,$02,$03,$02,$03,$02,$03,$02,$03,$02
        .byte $0A,$02,$07,$02,$0F,$03,$0B,$02,$03,$02,$02,$02,$03,$05,$02,$03
        .byte $02,$03,$02,$03,$02,$02,$02,$03,$02,$03,$03,$02,$02,$03,$02,$03
        .byte $03,$03,$03,$06,$02,$02,$03,$02,$02,$07,$03,$03,$02,$03,$02,$06
        .byte $03,$09,$02,$04,$02,$06,$02,$02,$03,$03,$05,$03,$03,$02,$02,$03
        .byte $04,$07,$03,$03,$02,$02,$03,$04,$05,$03,$03,$02,$03,$03,$03,$03
        .byte $06,$05,$07,$03,$23,$02,$02,$03,$02,$02,$03,$02,$03,$02,$02,$04
        .byte $03,$03,$02,$02,$03,$05,$05,$03,$03,$03,$03,$03,$02,$03,$04,$02
        .byte $03,$02,$03,$03,$04,$02,$02,$03,$03,$03,$03,$03,$05,$02,$03,$02
        .byte $02,$02,$02,$03,$02,$02,$02,$03,$02,$02,$03,$03,$03,$02,$02,$03
        .byte $04,$07,$05,$03,$03,$03,$02,$02,$03,$03,$02,$04,$03,$02,$03,$02
        .byte $02,$03,$05,$03,$05,$02,$03,$02,$04,$03,$07,$02,$05,$03,$02,$02
        .byte $03,$03,$04,$02,$03,$02,$03,$03,$04,$03,$02,$03,$03,$02,$02,$02
        .byte $05,$03,$03,$03,$03,$03,$02,$03,$03,$02,$02,$03,$0A,$03,$03,$03
        .byte $03,$03,$03,$01,$06,$02,$02,$03,$02,$03,$02,$02,$03,$02,$02,$02
        .byte $02,$03,$02,$03,$02,$05,$02,$11,$02,$03,$07,$03,$03,$02,$02,$02
        .byte $02,$03,$02,$06,$02,$02,$03,$02,$03,$02,$02,$03,$02,$02,$02,$03
        .byte $06,$03,$06,$05,$03,$04,$02,$02,$03,$03,$04,$03,$02,$02,$03,$02
        .byte $0A,$02,$03,$02,$03,$03,$04,$02,$04,$03,$07,$02,$03,$03,$03,$02
        .byte $04,$03,$03,$02,$03,$03,$02,$03,$02,$03,$02,$05,$03,$02,$03,$03
        .byte $03,$02,$02,$02,$03,$05,$02,$02,$03,$03,$02,$02,$05,$03,$03,$02
        .byte $02,$03,$03,$06,$02,$02,$02,$03,$03,$06,$06,$02,$03,$02,$02,$03
        .byte $02,$03,$02,$02,$03,$02,$03,$02,$04,$03,$02,$03,$02,$02,$03,$02
        .byte $02,$02,$03,$02,$02,$02,$03,$03,$02,$01,$02,$02,$03,$03,$05,$05
        .byte $04,$05,$05,$03,$06,$02,$03,$01,$03,$03,$09,$03,$02,$02,$02,$03
        .byte $05,$03,$02,$02,$02,$03,$02,$02,$03,$02,$02,$02,$03,$02,$02,$02
        .byte $03,$04,$04,$06,$04,$06,$05,$04,$06,$04,$03,$03,$02,$03,$04,$03
        .byte $04,$07,$04,$05,$04,$05,$04,$04,$02,$02,$03,$03,$05,$03,$07,$04
        .byte $05,$04,$04,$03,$02,$02,$03,$02,$03,$01,$04,$05,$03,$03,$07,$03
        .byte $05,$02,$02,$02,$04,$05,$06,$03,$06,$06,$03,$03,$06,$06,$03,$05
        .byte $04,$05,$03,$02,$02,$03,$03,$05,$07,$03,$05,$06,$04,$03,$08,$02
        .byte $03,$02,$02,$02,$03,$05,$04,$08,$03,$04,$03,$01,$02,$03,$02,$02
        .byte $03,$03,$02,$01,$03,$03,$06,$03,$05,$03,$05,$02,$02,$03,$02,$03
        .byte $02,$02,$07,$02,$03,$02,$02,$02,$03,$02,$03,$02,$02,$03,$01,$03
        .byte $02,$06,$06,$02,$06,$03,$09,$02,$05,$04,$06,$03,$06,$02,$02,$02
        .byte $03,$02,$02,$02,$03,$04,$05,$05,$04,$06,$03,$05,$06,$03,$06,$06
        .byte $03,$06,$06,$03,$03,$04,$07,$02,$02,$02,$04,$08,$03,$03,$05,$05
        .byte $06,$03,$07,$02,$03,$02,$02,$03,$03,$02,$02,$02,$03,$02,$02,$03
        .byte $06,$02,$02,$03,$03,$04,$03,$02,$03,$03,$03,$02,$02,$03,$03,$03
        .byte $02,$03,$03,$03,$02,$02,$03,$02,$0A,$03,$03,$07,$05,$02,$03,$02
        .byte $03,$02,$03,$03,$12,$02,$03,$02,$04,$02,$02,$03,$03,$02,$04,$03
        .byte $0B,$02,$02,$03,$1B,$02,$1B,$02,$03,$02,$03,$02,$05,$03,$07,$03
        .byte $67

     

    my sample is a kick


  2. now my code looks like this 

        processor f8
        org    $800

    ;------------;
    ; BIOS Calls ;
    ;------------;
    clrscrn    =     $00d0        ; uses r31
    delay        =     $008f        ; parameter in r5, uses r6
    pushk        =    $0107        ; uses r7, allows more subroutine stack space
    popk        =    $011e        ; uses r7 

    game_size    =    32


    CartridgeStart:
        .byte $55, $FB

        clr
        outs    0
        outs    1
        outs    4
    ;    ins    5
    ;    ni    %11000000            ; Keep audio bits as is (no click)
        outs    5

    CartridgeEntry: 

        dci    colordata
        lm
        xdc                    ; Store data counter for color in DC1

    clearagain:
        lr    3, A
        pi    clrscrn

        dci    sample_buffer    ; set data pointer to buffer
        clr
        com
        lr    0, A            ;output_state = 0

    outer_loop:
        clr                ; 1  cycle
        am                ; 2.5 cycles
        bz    end_sample
        lr    1, A            ; 1  cycle        Sample counter stores data


        lr    A, 0            ; 1  cycle        Fetch output state
        com                ; 1  cycle        Invert output state
    ;    ni    %11000000        ; 2.5 cycles    Only  keep the two sound bits
        lr    0, A            ; 1  cycle        Store for next data invert

        outs    5            ; 4 cycles        Put output state on port


        lr    A, 1            ; 1c
        outs    1            ; 2c    Color
        outs    4            ; 4c    Column
        li    %11100001        ; Set top two bits to 1
        ns    0            ; And with r0 to set any 0 in top two
        outs    5            ; 4c    Row
        lis    6            ; 1c
        sl    4            ; 1c
        outs    0            ; 2c
        sl    1            ; 1c
        outs    0            ; 2c


    inner_loop:
    ;    nop                ; 1 cycle
    ;    nop                ; 1 cycle
        nop                ; 1 cycle
        nop                ; 1 cycle
        nop                ; 1 cycle
        nop                ; 1 cycle


        ds    1            ; 1.5 cycles    Decrease sample counter
        bnz    inner_loop        ; 3.5 cycles branch, 3 cycles no branch
        br    outer_loop        ; 3.5 cycles


    end_sample:
        li    %00000000
        outs    5


        xdc                ; back to color 
        clr
        am                ; Add ram data to set flags
        xdc                ; Change back
        bnz    clearagain        ; Restart if not 0
        br    CartridgeEntry    ; Start over

    colordata:
        .byte $d6            ; grey
        .byte $c0            ; green
        .byte $21            ; b/w
        .byte $93            ; blue
        .byte 0
        .byte 0


    ;    jmp    CartridgeEntry
        
    sample_buffer:
        .byte $12,$02,$02,$07,$08,$03,$03,$02,$02,$07,$02,$03,$03,$03,$03,$03
        .byte $03,$0C,$02,$03,$02,$03,$03,$03,$02,$03,$0D,$02,$03,$03,$01,$0C
        .byte $07,$02,$03,$03,$02,$04,$02,$03,$04,$02,$03,$01,$06,$02,$03,$02
        .byte $03,$03,$02,$03,$0A,$06,$09,$02,$01,$05,$08,$02,$0A,$03,$04,$04
        .byte $08,$03,$02,$02,$01,$06,$06,$04,$02,$03,$02,$04,$02,$03,$02,$03
        .byte $02,$03,$02,$0B,$02,$0A,$03,$07,$01,$08,$08,$07,$05,$09,$02,$07
        .byte $07,$03,$03,$0A,$03,$0C,$04,$02,$15,$04,$04,$02,$03,$03,$01,$06
        .byte $03,$0A,$04,$03,$09,$03,$0A,$04,$04,$07,$02,$03,$03,$09,$08,$07
        .byte $01,$07,$02,$02,$01,$09,$04,$02,$03,$03,$03,$01,$0C,$04,$02,$04
        .byte $02,$02,$05,$0C,$03,$03,$01,$03,$07,$02,$08,$01,$06,$03,$02,$1A
        .byte $02,$03,$06,$03,$02,$01,$05,$08,$02,$04,$02,$03,$05,$04,$03,$05
        .byte $03,$02,$03,$01,$03,$02,$02,$02,$07,$03,$02,$01,$02,$03,$03,$01
        .byte $03,$04,$08,$03,$02,$05,$03,$02,$08,$04,$04,$04,$02,$03,$11,$03
        .byte $6B,$CA,$C8,$CA,$D2,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
        .byte 0

    ;===========================================================================
    ; Signature 
    ;===========================================================================


        ; signature
        org [$800 + [game_size * $400] -$10]

    ;signature:
        .byte "- e5frog - 2020 "
     

     

     

     

    is this good enough or am i missing something

     

     

     

     


  3. 7 minutes ago, e5frog said:

    That would be the second part of the text marked as code. 
    Save your data with filename "tetris.smp.inc" and use this code (which was the first part): 
    ... or change the name, or paste your code in there instead of the "include" statement. 

     

    	processor f8
    	org	$800
    
    ;------------;
    ; BIOS Calls ;
    ;------------;
    clrscrn	= 	$00d0		; uses r31
    delay		= 	$008f		; parameter in r5, uses r6
    pushk		=	$0107		; uses r7, allows more subroutine stack space
    popk		=	$011e		; uses r7 
    
    game_size	=	32
    
    
    CartridgeStart:
    	.byte $55, $FB
    
    	clr
    	outs	0
    	outs	1
    	outs	4
    ;	ins	5
    ;	ni	%11000000			; Keep audio bits as is (no click)
    	outs	5
    
    CartridgeEntry: 
    
    	dci	colordata
    	lm
    	xdc					; Store data counter for color in DC1
    
    clearagain:
    	lr	3, A
    	pi	clrscrn
    
    
    
    	dci	sample_buffer	; set data pointer to buffer
    	clr
    	com
    	lr	0, A			;output_state = 0
    
    outer_loop:
    	clr				; 1  cycle
    	am				; 2.5 cycles
    	bz	end_sample
    	lr	1, A			; 1  cycle		Sample counter stores data
    
    
    	lr	A, 0			; 1  cycle		Fetch output state
    	com				; 1  cycle		Invert output state
    ;	ni	%11000000		; 2.5 cycles	Only  keep the two sound bits
    	lr	0, A			; 1  cycle		Store for next data invert
    
    	outs	5			; 4 cycles		Put output state on port
    
    
    	lr	A, 1			; 1c
    	outs	1			; 2c	Color
    	outs	4			; 4c	Column
    	li	%11100001		; Set top two bits to 1
    	ns	0			; And with r0 to set any 0 in top two
    	outs	5			; 4c	Row
    	lis	6			; 1c
    	sl	4			; 1c
    	outs	0			; 2c
    	sl	1			; 1c
    	outs	0			; 2c
    
    
    inner_loop:
    ;	nop				; 1 cycle
    ;	nop				; 1 cycle
    	nop				; 1 cycle
    	nop				; 1 cycle
    	nop				; 1 cycle
    	nop				; 1 cycle
    
    
    	ds	1			; 1.5 cycles	Decrease sample counter
    	bnz	inner_loop		; 3.5 cycles branch, 3 cycles no branch
    	br	outer_loop		; 3.5 cycles
    
    
    end_sample:
    	li	%00000000
    	outs	5
    
    
    	xdc				; back to color 
    	clr
    	am				; Add ram data to set flags
    	xdc				; Change back
    	bnz	clearagain		; Restart if not 0
    	br	CartridgeEntry	; Start over
    
    colordata:
    	.byte $d6			; grey
    	.byte $c0			; green
    	.byte $21			; b/w
    	.byte $93			; blue
    	.byte 0
    	.byte 0
    
    
    ;	jmp	CartridgeEntry
    	
    sample_buffer:
    	include "tetris.smp.inc"
    	.byte 0
    
    
    
    ;===========================================================================
    ; Signature 
    ;===========================================================================
    
    
    	; signature
    	org [$800 + [game_size * $400] -$10]
    
    ;signature:
    	.byte "- e5frog - 2020 "

     

    well im thinking of adding my own sample so. Yeah. where do i add my own data and how do you rum .smp.inc files?


  4. 6 minutes ago, e5frog said:

    Only the first part is the actual used code, the other is an explanation how playing pwm is played in general. 

    If you put your data in a file called "tetris.smp.inc" you'd be able to run it right away. 

     

    so now my code looks like this

     

      sample_pointer = sample_buffer
      output_state = 0

    outer_loop:
      output_state = ~output_state
      sample_counter = [sample_pointer]
      ++sample_pointer

    inner_loop:
      output_state -> port
      --sample_counter
      if sample_counter != 0
       goto inner_loop
      goto outer_loop

    sample_buffer
      // PWM data goes here
        .byte $12,$02,$02,$07,$08,$03,$03,$02,$02,$07,$02,$03,$03,$03,$03,$03
        .byte $03,$0C,$02,$03,$02,$03,$03,$03,$02,$03,$0D,$02,$03,$03,$01,$0C
        .byte $07,$02,$03,$03,$02,$04,$02,$03,$04,$02,$03,$01,$06,$02,$03,$02
        .byte $03,$03,$02,$03,$0A,$06,$09,$02,$01,$05,$08,$02,$0A,$03,$04,$04
        .byte $08,$03,$02,$02,$01,$06,$06,$04,$02,$03,$02,$04,$02,$03,$02,$03
        .byte $02,$03,$02,$0B,$02,$0A,$03,$07,$01,$08,$08,$07,$05,$09,$02,$07
        .byte $07,$03,$03,$0A,$03,$0C,$04,$02,$15,$04,$04,$02,$03,$03,$01,$06
        .byte $03,$0A,$04,$03,$09,$03,$0A,$04,$04,$07,$02,$03,$03,$09,$08,$07
        .byte $01,$07,$02,$02,$01,$09,$04,$02,$03,$03,$03,$01,$0C,$04,$02,$04
        .byte $02,$02,$05,$0C,$03,$03,$01,$03,$07,$02,$08,$01,$06,$03,$02,$1A
        .byte $02,$03,$06,$03,$02,$01,$05,$08,$02,$04,$02,$03,$05,$04,$03,$05
        .byte $03,$02,$03,$01,$03,$02,$02,$02,$07,$03,$02,$01,$02,$03,$03,$01
        .byte $03,$04,$08,$03,$02,$05,$03,$02,$08,$04,$04,$04,$02,$03,$11,$03
        .byte $6B,$CA,$C8,$CA,$D2,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
     

     

    and why would converting it to .smp.inc make you be able to run it right away?

     


  5. On 5/11/2021 at 7:10 AM, e5frog said:

    Sample data is output with this code:

     

    	processor f8
    	org	$800
    
    ;------------;
    ; BIOS Calls ;
    ;------------;
    clrscrn	= 	$00d0		; uses r31
    delay		= 	$008f		; parameter in r5, uses r6
    pushk		=	$0107		; uses r7, allows more subroutine stack space
    popk		=	$011e		; uses r7 
    
    game_size	=	32
    
    
    CartridgeStart:
    	.byte $55, $FB
    
    	clr
    	outs	0
    	outs	1
    	outs	4
    ;	ins	5
    ;	ni	%11000000			; Keep audio bits as is (no click)
    	outs	5
    
    CartridgeEntry: 
    
    	dci	colordata
    	lm
    	xdc					; Store data counter for color in DC1
    
    clearagain:
    	lr	3, A
    	pi	clrscrn
    
    
    
    	dci	sample_buffer	; set data pointer to buffer
    	clr
    	com
    	lr	0, A			;output_state = 0
    
    outer_loop:
    	clr				; 1  cycle
    	am				; 2.5 cycles
    	bz	end_sample
    	lr	1, A			; 1  cycle		Sample counter stores data
    
    
    	lr	A, 0			; 1  cycle		Fetch output state
    	com				; 1  cycle		Invert output state
    ;	ni	%11000000		; 2.5 cycles	Only  keep the two sound bits
    	lr	0, A			; 1  cycle		Store for next data invert
    
    	outs	5			; 4 cycles		Put output state on port
    
    
    	lr	A, 1			; 1c
    	outs	1			; 2c	Color
    	outs	4			; 4c	Column
    	li	%11100001		; Set top two bits to 1
    	ns	0			; And with r0 to set any 0 in top two
    	outs	5			; 4c	Row
    	lis	6			; 1c
    	sl	4			; 1c
    	outs	0			; 2c
    	sl	1			; 1c
    	outs	0			; 2c
    
    
    inner_loop:
    ;	nop				; 1 cycle
    ;	nop				; 1 cycle
    	nop				; 1 cycle
    	nop				; 1 cycle
    	nop				; 1 cycle
    	nop				; 1 cycle
    
    
    	ds	1			; 1.5 cycles	Decrease sample counter
    	bnz	inner_loop		; 3.5 cycles branch, 3 cycles no branch
    	br	outer_loop		; 3.5 cycles
    
    
    end_sample:
    	li	%00000000
    	outs	5
    
    
    	xdc				; back to color 
    	clr
    	am				; Add ram data to set flags
    	xdc				; Change back
    	bnz	clearagain		; Restart if not 0
    	br	CartridgeEntry	; Start over
    
    colordata:
    	.byte $d6			; grey
    	.byte $c0			; green
    	.byte $21			; b/w
    	.byte $93			; blue
    	.byte 0
    	.byte 0
    
    
    ;	jmp	CartridgeEntry
    	
    sample_buffer:
    	include "tetris.smp.inc"
    	.byte 0
    
    
    
    ;===========================================================================
    ; Signature 
    ;===========================================================================
    
    
    	; signature
    	org [$800 + [game_size * $400] -$10]
    
    ;signature:
    	.byte "- e5frog - 2020 "
    

    I converted this code that was given to me by utz (Sleizsa Duo/Trio):
     

      sample_pointer = sample_buffer
      output_state = 0
    
    outer_loop:
      output_state = ~output_state
      sample_counter = [sample_pointer]
      ++sample_pointer
    
    inner_loop:
      output_state -> port
      --sample_counter
      if sample_counter != 0
       goto inner_loop
      goto outer_loop
    
    sample_buffer
      // PWM data goes here




    sample_buffer is where the sample data starts, the end is marked with $00. 

    Sample data is made from wav by a program called wav2pwm. 
    https://github.com/JeffAlyanak/pcm2pwm/releases

    I used a 44100kHz, 8-bit, mono-file saved as Windows PCM

    I was considering using an address-bit for output and have a small speaker in the cart but... feature creep. 

    Soo. Should i use both what do i call them and is this code here fine?

     

        .byte $12,$02,$02,$07,$08,$03,$03,$02,$02,$07,$02,$03,$03,$03,$03,$03

        .byte $03,$0C,$02,$03,$02,$03,$03,$03,$02,$03,$0D,$02,$03,$03,$01,$0C

        .byte $07,$02,$03,$03,$02,$04,$02,$03,$04,$02,$03,$01,$06,$02,$03,$02

        .byte $03,$03,$02,$03,$0A,$06,$09,$02,$01,$05,$08,$02,$0A,$03,$04,$04

        .byte $08,$03,$02,$02,$01,$06,$06,$04,$02,$03,$02,$04,$02,$03,$02,$03

        .byte $02,$03,$02,$0B,$02,$0A,$03,$07,$01,$08,$08,$07,$05,$09,$02,$07

        .byte $07,$03,$03,$0A,$03,$0C,$04,$02,$15,$04,$04,$02,$03,$03,$01,$06

        .byte $03,$0A,$04,$03,$09,$03,$0A,$04,$04,$07,$02,$03,$03,$09,$08,$07

        .byte $01,$07,$02,$02,$01,$09,$04,$02,$03,$03,$03,$01,$0C,$04,$02,$04

        .byte $02,$02,$05,$0C,$03,$03,$01,$03,$07,$02,$08,$01,$06,$03,$02,$1A

        .byte $02,$03,$06,$03,$02,$01,$05,$08,$02,$04,$02,$03,$05,$04,$03,$05

        .byte $03,$02,$03,$01,$03,$02,$02,$02,$07,$03,$02,$01,$02,$03,$03,$01

        .byte $03,$04,$08,$03,$02,$05,$03,$02,$08,$04,$04,$04,$02,$03,$11,$03

        .byte $6B,$CA,$C8,$CA,$D2,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF

     so. I dont understand anything


  6. 2 minutes ago, e5frog said:

    I can't, I haven't suceeded in doing so on a real machine, in emulation it works though, the emulation differs a lot from the real thing regarding sound.

    Things need to be explored further. 

     

    even if its on an emulator i am just curious how you did it on that tetris thing

×
×
  • Create New...