Apple ][2023. 4. 4. 16:28

 

 

Latch Address: This signal indiates that the bus contains a resister address which should be latched in the PSG. DA7~DA0 are in the input mode.

 

from 6522, ORB[0] = BC1, ORB[1] = BDIR, ORB[2] = ~RESET

 

ORB = 7 (111): Latch Address, sets register address

ORB = 6 (110): Write To PSG register

ORB = 4 (100): Inactive

ORB = 0~3 (0xx): Reset  : clears all registers

 

procedure: Command -> Inactive

 

* sets PSG register to N (0~15)

lda #N

sta ora  ; connected to psg data bus

lda #7   ; loads 'latch address' command

sta orb  ; sends the command. connected to bus controls (BDIR, BC1)

lda #4   ; loads inactive command

sta orb  ; sends the command

 

* writes data to PSG's current register

lda data

sta ora

lda #6    ; 'write to psg' command

sta orb

lda #4

sta orb

 

* reset

stz orb

lda #4

sta orb

 

==> PSG, R[2] = 2

set PSG register to 2 -> writes 2 to PSG

 

Register \ bit B7 B6 B5 B4 B3 B2 B1 B0
R0 Channel A Tone Period 8-Bit Fine Tune A
R1   4-Bit Coarse Tune A
R2 Channel B Tone Period 8-Bit Fine Tune B
R3   4-Bit Coarse Tune B
R4 Channel C Tone Period 8-Bit Fine Tune C
R5   4-Bit Coarse Tune C
R6 Noise period   5-Bit Period control
R7 Enable ( bit 0 = on, 1 = off ) IN/OUT Noise Tone
IOB IOA C B A C B A
R8 Channel A Envelope on/off, Volume   Env volume
R9 Channel B Envelope on/off, Volume   Env volume
R10 Channel C Envelope on/off, Volume   Env volume
R11 Envelope Period 8-Bit Fine Tune Envelope
R12   4-Bit Coarse Tune Envelope
R13 Envelope Shape/Cycle   CONT ATT ALT HOLD
R14 I/O Port A Data Store 8-Bit Parallel I/O on Port A
R15 I/O Port B Data Store 8-Bit Parallel I/O on Port B

* Enable output Channel A (R7 = 0011 1110)

 

 

 

Posted by GNUPart
Apple ][2023. 4. 3. 17:26

* datasheet

https://eater.net/datasheets/w65c22.pdf

 

 

* code exam.

https://github.com/fenarinarsa/Latecomer/blob/master/tools.a#L174

 

-sets timer

config_timer
    ; interruption - TIMER 1 6522
    LDA #%01000000      ; continuous interrupt / PB7 disabled
    ldy #$0B
    STA (MB_OUT),y      ; $Cx0B Auxiliary Control Register

    LDA #%11000000      ;
    ldy #$0D
    STA (MB_OUT),y      ; $Cx0D interrupt flag register (Time Out of Timer 1/Int)
    ldy #$0E
    STA (MB_OUT),y      ; $Cx0E interrupt Enable register (Timer 1 + Set)
   
    ; The 6522 timer to play at 50Hz is different on a PAL or NTSC Apple II
    ; Main Apple II clock is (composite frequency):
    ; PAL = 1.016 MHz
    ; NTSC = 1.0205 MHz
    ;
    ; For future reference the 6522 counter for a complete frame size should be set to
    ; PAL = $4F36 (50.08Hz) = 20280-2 cycles
    ; NTSC = $4284 (~59.94Hz) = 17030-2 cycles
    ;
    ; Of course on PAL Apple IIc the VSYNC interrupt may be used, it already has a frequency of 50.08Hz
    ;
    ; Because of the clock differences,
    ; to get a frequency 50.08Hz on an NTSC Apple II the 6522 counter should actually be set at $4F88
    ; but the difference is not big enough to be heard and I'm lazy
    ;
    ; We're using T1 (first timer) on MB's first 6522 (there is two timers/6522 and two 6522 on a MB)
    ; T1 is set in free run mode so the counter needs to be set up only once
    ; the timer will start and loop once the counter high byte is written

    LDA #$36
    ldy #$04
    STA (MB_OUT),y      ; $Cx04 T1C-Lower
    LDA #$4F
    ldy #$05
    STA (MB_OUT),y      ; $Cx05 T1C-High

    lda MB_OUT+1    ; modifies the BIT instruction in VBLI
    sta vbli_mod1+2
    +set_ptr VBLI_compatible,$FFFE  ; setting up the 50Hz interrupt handler

    rts

 

- interrupt routine

VBLI_compatible
    ; Interrupt handler for IIe/IIc, using a 50Hz mockingboard interrupt
    ; on PAL should activate roughly at the start of VBLANK
    ; on NTSC will activate quite anywhere => tearing :)

    php             ; save flags
    sta save_a
    stx save_x
    sty save_y

    lda #$7f
vbli_mod1   sta $C40D ; clear IFR
    ;bit $C404       ; Clears interrupt (T1CL)  / modified instruction

    ; change VBL flag
    ldx #0
    stx vblflag     ; clear hibit
   
    ;----- HGR double buffering
    lda vbl_swaphgr
    beq .noswap
    stx vbl_swaphgr
    jsr swap_page
.noswap +inc16 vbl_count
   
    ; play music
    lda music_on
    beq .no_music
    jsr player_mb
.no_music

    ldy save_y
    ldx save_x
    lda save_a
    plp
    rti

 

 

 

 

 

 

Posted by GNUPart
Unity2015. 12. 11. 17:52

Unity3D, Sprite, Sprite Pivot, Custom Editor, Pivot Edit, SceneView, 피벗, 피봇, 스프라이트, 설정, 씬뷰, 커스텀 에디터

 

 

 

 

 

 

 스프라이트를 이용한 캐릭터 작업시, 너무 번거로운 피벗세팅 때문에 만들게 되었습니다. 관련 패키지를 첨부합니다.

 

 

* 주요기능은 다음과 같습니다.

- Edits a pivot in SceneView ( 씬뷰에서 피벗을 설정할 수 있습니다. )

  - by presets ( 기본 설정값들로 작업 )

  - by dragging gizmo ( 피벗포인트를 드래그 )

  - by dragging object ( 해당 오브젝트를 드래그 )

 

- Gives pixel-perfect pivot option ( 픽셀에 맞춰 피벗을 설정할 수 있습니다. )

- Moves a gameobject along parent's pixel unit 

 ( 부모 스프라이트의 픽셀에 맞춰 오브젝트를 이동할 수 있습니다.)

 

- Supports Single/Multiple sprite mode.

 (싱글/멀티 스프라이트 모드, 모두에 사용가능합니다.) 

 

- Undo is not supported!!! ( Undo기능 없어요. 주의바랍니다. )

 

* 기능 구현에 사용한 방법은 다음과 같이 간단한 도메인 변환입니다.

- World-Position -> Local-Position -> Pivot

- Pivot -> Local-Position -> World-Position

 

첨부된 소스코드중,

zUtils.cs::zWorldPositionToPivot, zPivotToWorldPosition

을 참고바랍니다.

 

* Source codes

Editor/

  zCommonEditor.cs : Common editor utilities

  zSpriteEditor.cs : Editor-Template for SpriteRenderer

  zSpritePivotExt.cs : Custom sprite pivot editor (inherits from zSpriteEditor)

zUtils/

  zUtils.cs : Common utilities for sprite pivot

 

 

* Desciption

 

 NORMAL-MODE

 

- Lock Position : on pivot editing, prevents changing of local-position

( 피벗설정시, local-position이 움직이는 것을 방지합니다.)

 

- Align to Pixel : pivot is snapped to pixel-unit

( 픽셀단위로 피벗을 설정합니다. )

 

- Presets : default presets, like Center, TopLeft, BottomCenter, and so on

   ( 기존 피벗 프리셋입니다. )

 

- Edit : Change mode to EDIT-MODE, ( 피벗설정 모드로 전환합니다. )

 In EDIT-MODE, inspector and sceneview are shown as belows: 

 

 

- Apply : applies editted pivot ( It will change Asset ImportSetting directly )

설정된 피벗을 적용합니다.

- Cancel : cancels (취소)

 

- Copy : copies current pivot value (Vector2)

(현재 설정된 피벗값을 복사합니다.)

 

- Paste : pastes copied pivot to current sprite

(복사된 값을 현재 스프라이트에 적용합니다.)

 

* Press A-Key and move a gameobject : gameobject will move along its parent's pixel-unit.

 ( A키를 누른상태에서 오브젝트를 이동하면, 부모 스프라이트의 픽셀에 맞출수 있습니다. )

 

For more information, see the attached video. 첨부된 동영상에 좀더 자세한 설명이 있습니다.

 

 

Posted by GNUPart