.scope STARTUP
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
;;Settings positions
CR1 = $d011; ;Graphic settings
VIC_bank_settings = $DD00 ; Vic position
Screen_RAM_settings =$D018 ;Screen RAM position relative to VIC

;;########## VIC_BANK ################
;;#	BITMAP | $4000 -$5F3F
;;#  Unused? |  $5F3F - $6000
;;#	SCREAN RAM (color) | $6000 -$63E7
;;#  Unused? | $63E8 - $7FFF
;;#
;;####################################

;;Memory positions
VIC_bank = $4000
VIC_bank_end = VIC_bank + $3FFF

Bitmap = VIC_bank
Bitmap_end = $5F3F

Screen_RAM = $2000 + VIC_bank
Screen_RAM_end = Screen_RAM + $03E7

Character_generator_ROM = $D000

;;Free up memory
;;https://www.c64-wiki.com/wiki/Bank_Switching
;;
;;Set graphic mode [Standard bitmap mode]
;;https://www.c64-wiki.com/wiki/Standard_Bitmap_Mode
LDA #%10111111 ; ECM = False Extended color mode
AND CR1
STA CR1

LDA #%00100000; BMM = True Bitmap mode
ORA CR1
STA CR1

;;Set VIC bank to bank 1
;;https://www.c64-wiki.com/wiki/VIC_bank
LDA #%11111110 ;bit_0 = False
AND VIC_bank_settings
STA VIC_bank_settings

LDA #%00000010; bit_1 = True
ORA VIC_bank_settings
STA VIC_bank_settings

;;Set Scren-RAM to offset 8 ;https://www.c64-wiki.com/wiki/53272   (offset is 8k byte = 1024*8-ich)
LDA #%10001111 ; bit_6 =bit_5=bit_4 = Falsw
AND Screen_RAM_settings
STA Screen_RAM_settings

LDA #%10000000; bit_1 = True
ORA Screen_RAM_settings
STA Screen_RAM_settings

;;Paint the bitmap black. More bitmap: https://www.c64-wiki.com/wiki/53272, https://www.c64-wiki.com/wiki/Screen_RAM#Moving_of_screen_RAM
Mov_16 >B_start, <B_start, #<VIC_bank, #>VIC_bank
Mov_16 >B_end, <B_end, #<$5f3f,  #>$5f3f
LDA #$00
jsr memset


;;Sets the screen color to black and white
Mov_16 >B_start, <B_start, #<Screen_RAM, #>Screen_RAM
Mov_16 >B_end, <B_end, #<Screen_RAM_end, #>Screen_RAM_end
LDA #%11110000
jsr memset
SEI ;Disable interups (not all)
;;Disable BASIC ROM mohahaha
LDA #%11111110
AND $0001
STA $0001
;https://www.c64-wiki.com/wiki/Bank_Switching
;Disable IO, CHAREN =0
;LDA #%11111011
;AND $0001
;STA $0001
.endscope