# lab3 work in progress

We did it in class in a group
this one is in progress of adding one more digit, so it could show numbers from 00 to 99, but right now it is just has one digit active.

```
define WIDTH 	8 ; width of graphic
define HEIGHT 	8 ; height of graphic

define DIGIT		$10;
define DIGIT_HIGH	$11;
define DIGIT2           $14;
define DIGIT2_HIGH      $15;
define SCREEN		$12;
define SCREEN_HIGH	$13;
define ROWS		$20;
define DATA		$35;
define COLUMN		$40;
define INPUT		$ff;

	lda #<zero	; store digit
	sta DIGIT
	lda #>zero
	sta DIGIT_HIGH

	lda #<zero      ;store another digit
	sta DIGIT2
	lda #>zero
	sta DIGIT2_HIGH

 reset:	lda #$85	; pointer to the middle of the screen
 	sta SCREEN
 	lda #$03
 	sta SCREEN_HIGH
 
 	lda #$00	; number of rows we've drawn
 	sta ROWS
 
 	ldx #$00	; index for data
	stx DATA

 	ldy #$00	; index for screen column
	sty COLUMN

 draw:	ldy DATA
	lda (DIGIT),y	; get data
	inc DATA

	ldy COLUMN
	sta (SCREEN),y	; print data
	inc COLUMN

	lda COLUMN
 	cmp #WIDTH	; check if done printing row
 	bne draw	; if not done keep drawing
   
 	inc ROWS	; increment row counter
 
 	lda #HEIGHT	; check if done all printing
 	cmp ROWS
 	beq next	; ...exit if we are
 
 	lda SCREEN	; load pointer
 	clc
 	adc #$20	; add 32 to drop one row
 	sta SCREEN
 	lda SCREEN_HIGH	; carry to high byte if needed
 	adc #$00
 	sta SCREEN_HIGH
 
 	ldy #$00
	sty COLUMN	; reset column
 	beq draw

draw2:	ldy DATA
	lda (DIGIT),y	; get data
	inc DATA

	ldy COLUMN
	sta (SCREEN),y	; print data
	inc COLUMN

	lda COLUMN
 	cmp #WIDTH	; check if done printing row
 	bne draw	; if not done keep drawing
   
 	inc ROWS	; increment row counter
 
 	lda #HEIGHT	; check if done all printing
 	cmp ROWS
 	beq next	; ...exit if we are
 
 	lda SCREEN	; load pointer
 	clc
 	adc #$20	; add 32 to drop one row
 	sta SCREEN
 	lda SCREEN_HIGH	; carry to high byte if needed
 	adc #$00
 	sta SCREEN_HIGH
 
 	ldy #$00
	sty COLUMN	; reset column
 	beq draw
 
 next:	lda INPUT
	beq next	; wait for key input (- and +)

	ldx #$00	; reset input pointer
	stx INPUT

	cmp #$2d
	beq minus	; - pressed?
	cmp #$3d
	beq plus	; + pressed?
	jmp next	; infinitely loop

 minus:	lda DIGIT
	cmp #<zero
	bne mfin	; is it not zero?

	ldx DIGIT_HIGH
	cpx #>zero
	beq mfin2	; is it zero?

 mfin:	sec		; set carry
	sbc #$40	; subtract 64
	sta DIGIT
	lda DIGIT_HIGH
	sbc #$00	; subtract carry
	sta DIGIT_HIGH
	jmp reset

 mfin2:	lda #<nine	; change digit to nine
	sta DIGIT
	lda #>nine
	sta DIGIT_HIGH
	jmp reset

 plus:	lda DIGIT
	cmp #<nine
	bne pfin	; is it not nine?

	ldx DIGIT_HIGH
	cpx #>nine
	beq pfin2	; is it nine?

 pfin:	clc		; clear carry
	adc #$40	; add 64
	sta DIGIT
	lda DIGIT_HIGH
	adc #$00	; add carry
	sta DIGIT_HIGH
	jmp reset

 pfin2:	lda #<zero	; change digit to zero
	sta DIGIT
	lda #>zero
	sta DIGIT_HIGH
	jmp reset

zero:
dcb 0,0,1,1,1,1,0,0
dcb 0,1,1,0,0,1,1,0
dcb 0,1,1,0,1,1,1,0
dcb 0,1,1,1,0,1,1,0
dcb 0,1,1,0,0,1,1,0
dcb 0,1,1,0,0,1,1,0
dcb 0,0,1,1,1,1,0,0
dcb 0,0,0,0,0,0,0,0

one:
dcb 0,0,0,1,1,0,0,0
dcb 0,0,0,1,1,0,0,0
dcb 0,0,1,1,1,0,0,0
dcb 0,0,0,1,1,0,0,0
dcb 0,0,0,1,1,0,0,0
dcb 0,0,0,1,1,0,0,0
dcb 0,1,1,1,1,1,1,0
dcb 0,0,0,0,0,0,0,0

two:
dcb 0,0,1,1,1,1,0,0
dcb 0,1,1,0,0,1,1,0
dcb 0,0,0,0,0,1,1,0
dcb 0,0,0,0,1,1,0,0
dcb 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