Embracing Creativity: The Evolution of "Dumb Daniel"
Tags: coding, assembly
Published: 2024-05-23 20:32:01

Welcome back to the final installment of our journey into the world of 6502 assembly programming! If you've been following along, you're already familiar with "Dumb Daniel," our trusty companion on this adventure. Today, we're diving into the latest chapter of our story as "Dumb Daniel" undergoes a remarkable transformation, evolving from a humble arithmetic calculator into a mesmerizing display of colors on the screen.

## A Journey of Discovery
Our journey with "Dumb Daniel" began with a simple goal: to create the easiest program possible within the confines of 6502 assembly. Armed with determination and a sense of curiosity, we set out to conquer the world of assembly programming, one instruction at a time.

## Unforeseen Challenges
As we delved deeper into the intricacies of 6502 assembly, we encountered our fair share of challenges and surprises. From unexpected arithmetic quirks to the limitations of the emulator, each obstacle presented an opportunity for growth and learning.

## The Birth of "Dumb Daniel"
Out of these challenges emerged "Dumb Daniel," a quirky creation born out of necessity and ingenuity. With its humble beginnings as a simple arithmetic calculator, "Dumb Daniel" quickly captured our imagination and led us on a journey of exploration and discovery.

## A Twist of Fate: Embracing Creativity
But as our journey progressed, we found ourselves craving something more than just arithmetic operations. We longed to unleash our creativity and push the boundaries of what was possible within the constraints of the emulator. And so, we made a bold decision to transform "Dumb Daniel" into something truly extraordinary.

## The Evolution Unveiled: Colorful Creations
With a few simple tweaks to our code, "Dumb Daniel" underwent a remarkable transformation, blossoming into a vibrant display of colors on the screen. From bold blues to fiery reds, each pixel became a canvas for our imagination, allowing us to create intricate patterns and mesmerizing displays.

## Embracing the Future
As we bid farewell to our colorful creation, we can't help but wonder what lies ahead for "Dumb Daniel." Will it continue to evolve and adapt to new challenges, or will it pave the way for even more daring experiments? Only time will tell, but one thing is certain: the journey is far from over.

## Join Us on the Adventure
Thank you for joining us on this exhilarating journey through the world of 6502 assembly programming. Whether you're a seasoned programmer or a curious novice, we invite you to join us on our quest for knowledge and exploration.

With "Dumb Daniel" by our side, we're ready to embark on new adventures and continue pushing the boundaries of what's possible in the world of assembly programming. Until next time, happy coding!

## Code Reveal

```
; ROM routines
define		SCINIT		$ff81 ; initialize/clear screen
define		CHRIN		$ffcf ; input character from keyboard
define		CHROUT		$ffd2 ; output character to screen
define		SCREEN		$ffed ; get screen size
define		PLOT		$fff0 ; get/set cursor coordinates

; Memory locations
define		INPUT		$2000 ; input buffer (up to 5 chars)

	jsr SCINIT
	
	ldy #$00
printString:
	lda string,y
	beq done
	jsr CHROUT
	iny
	bne printString

done:
	jsr readinput
		
	lda #$0D
	jsr CHROUT

	ldy #$00
print_input:
	lda INPUT,y
	jsr CHROUT
	iny
	cpy #$05
	bne print_input
	
	brk


string:
	dcb "I","f",32,"y","o","u",32,"w","a","n","t",32,"t","o",32,"s","e","e",32"m","a","g","i","c",32,"t","h","e","n",32,"t","y","p","e",32,"m","a","g","i","c",32,"a","n","d",32,"p","r","e","s","s",32,"e","n","t","e","r",32,"t","w","i","c","e",32,00

; ---------------------------------------------------------------
readinput:
	lda #$A0
	jsr CHROUT
	lda #$83
	jsr CHROUT

	ldy #$00

read_char:
	jsr CHRIN
	CMP #$00
	beq read_char

	cmp #$08
	bne check_enter

	cpy #$00
	beq read_char
	
	dey
	lda #$20
	jsr CHROUT
	lda #$83
	jsr CHROUT
	jsr CHROUT
	lda #$A0
	jsr CHROUT
	LDA #$83
	jsr CHROUT

check_enter:
	cmp #$0D
	bne check_letter
	cpy #$05
	beq execute


	
check_letter:
	cmp #97
	bcc uppercase
	
	cmp #123
	bcs read_char
	
	sec
	sbc #32

uppercase:
	cmp #65
	bcc read_char

	cmp #91
	bcs read_char

	cpy #$05
	beq read_char

	sta INPUT,y
	jsr CHROUT	
	
	lda #$A0
	jsr CHROUT
	lda #$83
	jsr CHROUT
	
	iny
	
	jmp read_char

done_input:
	lda #$20
	jsr CHROUT
	
	;rts

execute:
	ldy #$00
loop:   lda #$e     ; colour number
    	sta $0200,y ; set pixel colour at page 2+y
    	lda #$f     ; colour number
        sta $0300,y     ; set pixel colour at page 3+y
    	lda #$3     ; colour number
        sta $0400,y     ; set pixel colour at page 4+y
    	lda #$a     ; colour number
        sta $0500,y     ; set pixel colour ar page 5+y
    	iny     ; increment index
    	bne loop    ; continue until done the page (256 pixels)
	
```
Credits to my professor Chris Tyler for providing the code of getting input from the keyboard.