Sufficiency Economy
Group Blog
 
All blogs
 
snes : แสดงภาพบน Background



ตอนรับ การได้มาของ SNES MINI โซนยุโรป (ไม่เอาของ อเมริกา เพราะไม่สวยอย่าแรง ) ตามจริงอยากได้แบบญี่ปุ่น แต่อ่านภาษาอังกฤษง่ายกว่า ^^

และมีการ hack ให้เพิ่มเกมส์ได้ ด้วย hackchi2 
ก็เลย มาเขียนโปรแกรม snes เล่นดีกว่า โดยจะแสดงรูปนี้ด ขนาด 72 x 88 ใน mode 1
ที่มี background 3 layer 
BG1 16 สี
BG2 16 สี
BG3  4 สี

แต่เราจะแสดงบน BG1

ต้องแปลงเป็น format : PCX แล้ว convert เป็น data ที่ snes อ่านง่าย ด้วยโปรแกรม pcx2snesWIN

เขียน code และ compile หรือ assembler หว่า? ให้เป็น .smc

Code ก็ประมาณนี้
;============================================================================
; Includes
;============================================================================

;== Include MemoryMap, Vector Table, and HeaderInfo ==
.INCLUDE "header.inc"

;== Include SNES Initialization routines ==
.INCLUDE "InitSNES.asm"
.INCLUDE "LoadGraphics.asm"


;============================================================================
; Main Code
;============================================================================

.BANK 0 SLOT 0
.ORG 0
.SECTION "MainCode"

Start:
    InitSNES    ; Clear registers, etc.

    ; Load Palette for our tiles
    LoadPalette BG_Palette, 0, 16

    ; Load Tile data to VRAM
    LoadBlockToVRAM Tiles, $0000, $0C60 ; 99 tiles  = 3168 bytes

; Address Tiles Map BG1 setting
    lda #$00
    sta $2115
; Input Tiles Map
ldx #$3000 ; $6000 line = 1
    stx $2116
    lda #$00
- sta $2118
    inc a
    cmp #$9
bne -


ldx #$3020 ; $6000 line = 2
    stx $2116 
lda #$09
- sta $2118
    inc a
    cmp #$12
bne -
ldx #$3040 ; $6000 line = 3
    stx $2116 
lda #$12
    sta $2118
    lda #$13
    sta $2118
lda #$14
    sta $2118
lda #$15
    sta $2118
    lda #$16
    sta $2118
lda #$17
    sta $2118
lda #$18
    sta $2118
    lda #$19
    sta $2118
lda #$1A
    sta $2118

ldx #$3060 ; $6000 line = 4
    stx $2116 
lda #$1B
- sta $2118
    inc a
    cmp #$24
bne -
ldx #$3080 ; $6000 line = 5
    stx $2116 
lda #$24
- sta $2118
    inc a
    cmp #$2D
bne -
ldx #$30A0 ; $6000 line = 6
    stx $2116 
lda #$2D
- sta $2118
    inc a
    cmp #$36
bne -
ldx #$30C0 ; $6000 line = 7
    stx $2116 
lda #$36
- sta $2118
    inc a
    cmp #$3F
bne -
ldx #$30E0 ; $6000 line = 8
    stx $2116 
lda #$3F
- sta $2118
    inc a
    cmp #$48
bne -

ldx #$3100 ; $6000 line = 9
    stx $2116 
lda #$48
- sta $2118
    inc a
    cmp #$51
bne -
ldx #$3120 ; $6000 line = 10
    stx $2116 
lda #$51
- sta $2118
    inc a
    cmp #$5A
bne -
ldx #$3140 ; $6000 line = 11
    stx $2116 
lda #$5A
- sta $2118
    inc a
    cmp #$63
bne -
    ; Setup Video modes and other stuff, then turn on the screen
    jsr SetupVideo
Infinity:
    jmp Infinity    ; bwa hahahahaha


;============================================================================
; SetupVideo -- Sets up the video mode and tile-related registers
;----------------------------------------------------------------------------
; In: None
;----------------------------------------------------------------------------
; Out: None
;----------------------------------------------------------------------------
SetupVideo:
    php

    lda #$01
    sta $2105           ; Set Video mode 1, 8x8 tiles, 16 color BG1/BG2/ ,4 color BG3

    lda #$30            ; Set BG1's Tile Map offset to $6000 (Word address)
    sta $2107           ; And the Tile Map size to 32x32

    stz $210B           ; Set BG1's Character VRAM offset to $0000 (word address)

    lda #$01            ; Enable BG1
    sta $212C

    lda #$FF
    sta $210E
    sta $210E

    lda #$0F
    sta $2100           ; Turn on screen, full Brightness

    plp
    rts
;============================================================================
.ENDS

;============================================================================
; Character Data
;============================================================================
.BANK 1 SLOT 0
.ORG 0
.SECTION "CharacterData"

    .INCLUDE "man1.inc"

.ENDS

=======================
ผลก็ประมาณนี้


วางจะลองไปใส่ใน snes mini ^0^
โดยศึกษาจาก https://wiki.superfamicom.org/
ในหมวด tutorial
Link นี้ก็น่าสนใจ https://github.com/PeterLemon/SNES





Create Date : 04 พฤศจิกายน 2560
Last Update : 4 พฤศจิกายน 2560 18:17:09 น. 0 comments
Counter : 991 Pageviews.

ชื่อ :
Comment :
  *ใช้ code html ตกแต่งข้อความได้เฉพาะสมาชิก
 

wink99_th
Location :
พิษณุโลก Thailand

[Profile ทั้งหมด]

ฝากข้อความหลังไมค์
Rss Feed
Smember
ผู้ติดตามบล็อก : 8 คน [?]




New Comments
Friends' blogs
[Add wink99_th's blog to your web]
Links
 

 Pantip.com | PantipMarket.com | Pantown.com | © 2004 BlogGang.com allrights reserved.