{"action":"created","issue":{"url":"https://api.github.com/repos/andreasjhkarlsson/gbdk-n/issues/10","repository_url":"https://api.github.com/repos/andreasjhkarlsson/gbdk-n","labels_url":"https://api.github.com/repos/andreasjhkarlsson/gbdk-n/issues/10/labels{/name}","comments_url":"https://api.github.com/repos/andreasjhkarlsson/gbdk-n/issues/10/comments","events_url":"https://api.github.com/repos/andreasjhkarlsson/gbdk-n/issues/10/events","html_url":"https://github.com/andreasjhkarlsson/gbdk-n/issues/10","id":202015870,"node_id":"MDU6SXNzdWUyMDIwMTU4NzA=","number":10,"title":"Interrupt handler hangs","user":{"login":"mmuszkow","id":3638997,"node_id":"MDQ6VXNlcjM2Mzg5OTc=","avatar_url":"https://avatars2.githubusercontent.com/u/3638997?v=4","gravatar_id":"","url":"https://api.github.com/users/mmuszkow","html_url":"https://github.com/mmuszkow","followers_url":"https://api.github.com/users/mmuszkow/followers","following_url":"https://api.github.com/users/mmuszkow/following{/other_user}","gists_url":"https://api.github.com/users/mmuszkow/gists{/gist_id}","starred_url":"https://api.github.com/users/mmuszkow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mmuszkow/subscriptions","organizations_url":"https://api.github.com/users/mmuszkow/orgs","repos_url":"https://api.github.com/users/mmuszkow/repos","events_url":"https://api.github.com/users/mmuszkow/events{/privacy}","received_events_url":"https://api.github.com/users/mmuszkow/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-01-20T00:31:11Z","updated_at":"2018-09-28T20:31:13Z","closed_at":null,"author_association":"NONE","body":"When I try to handle interrupts using the `add_JOY`, `add_VBL` etc. functions, the emulator (BGB) hangs after the handler is called for the first time. The code I used for test:\r\n```\r\n#include <gb/gb.h>\r\n#include <gb/rand.h>\r\n\r\nUINT8 tiles[64], i, jp;\r\n\r\nvoid joypad_irq() {\r\n    jp = joypad();\r\n    set_bkg_tiles(0, 0, 1, 1, &jp);\r\n}\r\n\r\nvoid main() {\r\n    disable_interrupts();\r\n    DISPLAY_OFF;\r\n    for(i=0; i<64; i++)\r\n        tiles[i] = _rand();\r\n    set_bkg_data(0, 128, tiles);\r\n    SHOW_BKG;\r\n    DISPLAY_ON;\r\n    \r\n    /* this hangs */\r\n    add_JOY(joypad_irq);\r\n    enable_interrupts();\r\n    set_interrupts(JOY_IFLAG);\r\n    while(1) { }\r\n    \r\n    /* this works */\r\n    //enable_interrupts();\r\n    //while(1) { joypad_irq(); }\r\n}\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/andreasjhkarlsson/gbdk-n/issues/comments/425557338","html_url":"https://github.com/andreasjhkarlsson/gbdk-n/issues/10#issuecomment-425557338","issue_url":"https://api.github.com/repos/andreasjhkarlsson/gbdk-n/issues/10","id":425557338,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNTU1NzMzOA==","user":{"login":"Robbi-Blechdose","id":7304526,"node_id":"MDQ6VXNlcjczMDQ1MjY=","avatar_url":"https://avatars1.githubusercontent.com/u/7304526?v=4","gravatar_id":"","url":"https://api.github.com/users/Robbi-Blechdose","html_url":"https://github.com/Robbi-Blechdose","followers_url":"https://api.github.com/users/Robbi-Blechdose/followers","following_url":"https://api.github.com/users/Robbi-Blechdose/following{/other_user}","gists_url":"https://api.github.com/users/Robbi-Blechdose/gists{/gist_id}","starred_url":"https://api.github.com/users/Robbi-Blechdose/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Robbi-Blechdose/subscriptions","organizations_url":"https://api.github.com/users/Robbi-Blechdose/orgs","repos_url":"https://api.github.com/users/Robbi-Blechdose/repos","events_url":"https://api.github.com/users/Robbi-Blechdose/events{/privacy}","received_events_url":"https://api.github.com/users/Robbi-Blechdose/received_events","type":"User","site_admin":false},"created_at":"2018-09-28T20:31:13Z","updated_at":"2018-09-28T20:31:13Z","author_association":"NONE","body":"This might be related to how you use the hardware here. What does \"set_interrupts()\" do? Anyway, try moving it before the interrupt enabler, and put a halt (whatever the C equivalent is) into your loop."}}
{"actor":{"display_login":"Robbi-Blechdose"}}